The src/test/java in a maven module is not recognized as Test Sources Root
Answered
Hi,
I am facing a strange issue, it seems.
I have a multi module maven project. One of the modules has this structure (no src/main folder).
src/test
- java
- resources
The java and resources folders are not recognized as Test Sources Root and Test Resources Root. Hence the java classes show a red circle like icon and not able to run the java files from the editor.
This happens only in this module. Other modules are fine.
- I tried deleting the project (including .idea folder) and reimport and it still doesn't work.
- When I try to mark the src/test/java as Test Sources Root, it marks src/main/java as Test Sources Root.
Can anyone provide any suggestions?
Please sign in to leave a comment.
Do you override the default roots in pom.xml?
Do you mean in module settings? In the process of looking for solutions, I tried removing the default root (the module itself) and added it back. Please find a screen shot below.
Changing module settings in a Maven based project makes no sense since they will be overwritten on the next Maven project reimport/refresh.
I mean this: http://stackoverflow.com/questions/19140873/change-source-directory-in-profile-maven.
Thank you for the reference. Let me check it out.
Hi Serge,
I checked and I am not modifying the default roots in pom. I have a build section in this module and a couple of plugins were configured there. That's it.
Please share the sample project to reproduce.
Serge,
That's what the difficulty is. I have several projects which follow the same structure and it is happening only on this project/module. I have recorded the screen and shared it at https://drive.google.com/drive/folders/0B9ZTG1k1oIcDcHZOUlh4d21uMm8?usp=sharing. Kindly take a look.
Please share if you have any suggestions.
Can you share the pom.xml file from the functional-test module, the root pom.xml file, .idea directory and all the .iml files? You can upload them privately: https://intellij-support.jetbrains.com/hc/articles/206869619.
Same issue here
https://github.com/OpenTOSCA/winery/blob/defeb030b265cc8571d1d494295fb3b286e73311/org.eclipse.winery.repository.ui.test/pom.xml#L5 and https://github.com/OpenTOSCA/winery/blob/defeb030b265cc8571d1d494295fb3b286e73311/pom.xml#L20
Which specific module/directory is not recognized as test resource for this project? It would be better if you could file a bug at https://youtrack.jetbrains.com/issues/IDEA with the link to the project and a screenshot of the problem.
I know this is 3 years later but someone might find this useful. I had a similar problem. My issue was the `@Test` annotation. Verify that the annotation is imported from the expected package. When the import was automatically resolved it was done from a different package. In my case it was imported from `org.junit` instead of `org.junit.jupiter.api`.