eclipse-buildship / buildship

The Eclipse Plug-ins for Gradle project.
535 stars 171 forks source link

JUnit test fails because wrong platform is used #1264

Closed danielerepici closed 1 year ago

danielerepici commented 1 year ago

Expected Behavior

A test within a project depending on JUnit 5.8.3 should be run with a platform launcher of that version.

Current Behavior

Eclipse junit-platform-launcher is picked over the project one. In this case it was 5.10.0 which contains a method org.junit.platform.engine.TestDescriptor.getAncestors() which is not present in 5.8.3 therefore the test fails with a NoSuchMethodError exception.

Context

Just trying to debug my tests.

Steps to Reproduce

Minimal example provided in this SO page: https://stackoverflow.com/questions/77110882/i-cant-run-junit5-tests-with-eclipseversion-2023-09-4-29-0

See also: https://stackoverflow.com/questions/77149537/nosuchmethod-on-junit-test-after-upgrading-eclipse-using-gradle

Your Environment

Java 17 Eclipse 2023-09 Spring Boot 2.6.3 Gradle wrapper 7.6

danielerepici commented 1 year ago

Sorry just realized it has already been reported here: https://github.com/eclipse/buildship/issues/1265

howlger commented 1 year ago

Thanks. Actually, you reported it just before I did. ⁠😉

djkdevise commented 11 months ago

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/