| Summary: | [JUnit] Run as Junit test fails for Junit4 tests | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Albert Tregnaghi <albert.tregnaghi> | ||||
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> | ||||
| Status: | RESOLVED NOT_ECLIPSE | QA Contact: | |||||
| Severity: | major | ||||||
| Priority: | P3 | CC: | jarthana, noopur_gupta | ||||
| Version: | 4.16 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Linux | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Albert Tregnaghi
Moving to UI where Junit support belongs. I do not see this issue on upgrade in Eclipse SDK using only JDT JUnit support. The JUnit version is correctly updated to use JUnit 5.6 container in a simple Java project. Are you using Maven or Gradle? Which JUnit version is being used there? Created attachment 283480 [details]
Demo spring boot application
A simple demo application using spring boot + old junit4 test - you must call ./gradlew cleanEclipse eclipse before importing
## My tries to reproduce the problem ### Create a simple demo app I created a simple demo application and uploaded it to this issue. The strange thing is, this is a similar setup as in my real application and when I do ./gradlew cleanEclipse eclipse + import existing projects #### Not reproducable And call "run as Junit test" on IamJunit4Test.java this works inside a new workspace and also inside my existing workspace where I have got the problems (both 2020-06 workspace format) ### Check if this was a conversion error of workspace I thought about a conversion problem from workspace 2019-12 to 2020-06 ### Import demo application in a fresh 2019-12 workspace So I downloaded a 2019-12 eclipse Java IDE and created a new workspace there. imported demo application into the 2019-12 workspace and then started Junit4 test. All working. ### Start 2020-06 eclipse with created 2019-12 workspace and let convert After starting former created workspace with 2020-06 and applying the conversion dialog I tried to start the existing launch configuration again. and... It is working !?! ### Mixed up demo project with junit5 jupiter test created a new jupiter (junit5) test - then started junit5 test (worked) - then started all tests inside project (worked) - then started junit4 test alone (worked) This looks like the Gradle/buildship issue mentioned in bug 561797 which is being tracked in https://github.com/eclipse/buildship/issues/980. Please check the workarounds mentioned in those bug reports until the problem is resolved. *** This bug has been marked as a duplicate of bug 561797 *** As shown in my last comments I was ble to reproduce by given spring demo application. But creating a new workspace 2020-06 and importing my existing projects (inclusive .gradlew cleanEclipse eclipse) did not fix my problems. ## Final solution ### tl;dr In build.gradle add next line: testImplementation 'org.junit.platform:junit-platform-launcher' ### Long story I searched around and found following: https://github.com/spring-projects/sts4/issues/431 (I am currently still using spring boot 2.2.x which brings up an older JUnit5 dependency which is not compatible with new Junit5 launcher in eclipse - demo app did use newer spring boot... thats the point...) So the correct solution is to add testImplementation 'org.junit.platform:junit-platform-launcher' into your gradle build when you are using an older spring boot version than 2.3.0! There is already a discussion with eclipse team (at least I hope so). Having this solved for myself I close this issue I fixed the problem for my situation by adding testImplementation 'org.junit.platform:junit-platform-launcher' into my gradle build. The problem is discussed at https://github.com/eclipse/buildship/issues/980 |