'My JUnit tests executes with maven build in Java 11, but unable to run same Junit tests via RunIT->Run As->Units, which always says not JUnits found
My module test project is supposed to be built using Java 11 as it is referencing to a jar which is build in Java 11. Hence I had to compile my code in Java 11. When I do Maven clean install, my JUnit test cases are executed without any issue. But when I tried to run my test cases via RunIT->Run As-> JUnit tests, it says "no JUnit tests found"
- When I first set up this project, I was able to run via RunIT->Run As-> JUnit tests, which worked absolutely fine. But I had another module in my workspace, which was working on Java 1.8. After testing the tests in that module and coming back to my test project, this stopped working.
- When I set compiler to Java 1.8, my tests are identified
Following are the configurations I have tried with
- I am working on Eclipse Java 2019-03, which supports Java 11
- I have set Preferences-> java -> Compiler -> Compiler compliance level to 11, and Installed JREs point to Java 11.
- Project -> Properties -> Java Build Path -> Libraries -> set to Java 11
- Project -> Properties -> Java Compiler -> set to Java 11
- In my module pom, I am referencing to JUnit 4
- While executing RunIT-> Run As -> Run Configurations, I have selected Java 11 JRE.
- I have done maven clean install, and all the test-classes are present in the expected target folder. I have Maven-> clean, deletes the target folder.
- After building my project via Maven, I have done "Maven Update" as well.
In my module pom file, I have set compiler version
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>11</source>
<target>11</target>
<encoding>${project.build.sourceEncoding}</encoding>
<testSource>11</testSource>
<testTarget>11</testTarget>
</configuration>
</plugin>
Solution 1:[1]
The issue got solved by opening the Java 11 project in different workspace. Before that I ensure that JAVA_HOME is set with to JAVA 11 and then open the eclipse.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Divya J |