-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NoSuchMethodError when running a JUnit 5.9.3 test in Eclipse 2023-09 (4.29) #1265
Comments
Thank you @howlger for your detailed analyses. As mentioned, when the With Maven this is no problem, because m2e adds the missing JUnit launcher with a matching version: The clean way to solve this problem with Gradle/Buildship is to include the missing
Unfortunately, when you do not change the Gradle version in Window > Preferences > Gradle the New Gradle Project Wizard in Buildship uses Gradle 8.1.1 and the Build Init Plugin from this distribution does not add this dependency. In my opinion, this gives not the best first-time user experience. The execution of JUnit tests on command line or with Run As > Gradle Test is no problem, because then the missing dependency is added at runtime. But this feature is deprecated and will be removed:
To improve the first-time user experience in Eclipse, Buildship should be updated to reference a newer Gradle distribution. |
En mi caso particular este error se soluciono siguiendo estos pasos: Una vez abierto el proyecto, haz clic derecho sobre él y elige Properties -> Java Build Path. Activa la pestaña Libraries y haz clic sobre Add Library… Selecciona JUnit -> Next -> Finish -> Apply and close Recuerda que también puedes añadir la librería a través de Maven, pero yo he añadido la librería de esta forma, que es igual de válida. Observa que se han añadido todas las librerías correspondientes a JUnit 5 a tu proyecto. tomado de: https://developrogramming.com/testear-con-junit-5/ |
Running a JUnit 5.9.3 test (e.g. via right-click and choosing Run As > JUnit Test) fails in Eclipse 2023-09 (4.29) with
NoSuchMethodError
.build.gradle
to reproduce this issue:JUnit 5 test to reproduce this issue:
Following stack trace will be printed to the Console view:
Workarounds:
build.gradle
, add the dependencytestImplementation 'org.junit.platform:junit-platform-launcher:1.9.3'
ortestImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
or-Pjunit-jupiter.version=5.10.0
(see @danielerepici's Stack Overflow answer)Cause:
It seems Buildship does not choose the corresponding
junit-platform-launcher
(as m2e seems to do; at least this issue cannot be reproduced with Maven), but uses thejunit-platform-launcher
version that is shipped with Eclipse. And in Eclipse 4.29junit-platform-launcher
has been upgraded to 1.10.0. Butorg.junit.platform:junit-platform-launcher:1.10.0
callsorg.junit.platform.engine.TestDescriptor.html::getAncestors
which has been introduced inorg.junit.platform:junit-platform-engine:1.10.0
and which is missing inorg.junit.platform:junit-platform-engine:1.9.3
in JUnit 5.9.3.See also the following Stack Overflow questions:
The text was updated successfully, but these errors were encountered: