bonigarcia/mastering-junit5

junit-jupiter-engine should be in dependencies to run it from Eclipse

LorenzoBettini opened this issue · 1 comments

If you put junit-jupiter-engine as a dependency in surefire configuration only, then the tests can't be run in Eclipse with an exception (see below).

Note that junit-jupiter-engine is in the main dependencies section also in the official JUnit Maven example, https://github.com/junit-team/junit5-samples/blob/r5.0.3/junit5-vanilla-maven/pom.xml

I'l submit a PR shortly (only for the hello project)

java.lang.NoClassDefFoundError:
org/junit/platform/engine/EngineDiscoveryRequest
	at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:59)
	at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.<init>(JUnit5TestLoader.java:31)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at java.lang.Class.newInstance(Class.java:442)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createRawTestLoader(RemoteTestRunner.java:367)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createLoader(RemoteTestRunner.java:362)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.defaultInit(RemoteTestRunner.java:306)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.init(RemoteTestRunner.java:221)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:205)
Caused by: java.lang.ClassNotFoundException:
org.junit.platform.engine.EngineDiscoveryRequest
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 12 more

Sorry for the late reply, and thank you very much for the PR! It has already available. I will change the rest of examples accordingly, thanks again.