question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.NoSuchMethodError: org.junit.platform.commons.util.Preconditions.notNull

See original GitHub issue

When running tests, get this:

Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform.commons.util.Preconditions.notNull([Ljava/lang/Object;Ljava/lang/String;)[Ljava/lang/Object;
	at org.junit.platform.launcher.core.DefaultLauncher.registerTestExecutionListeners(DefaultLauncher.java:71)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:37)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Any idea?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mannodermauscommented, Jun 13, 2017

Okay, AS 2.3.3 is most likely the culprit here. The blog post you linked to at the top of this issue described how IJ 2016.x is compiled against an older milestone of JUnit 5. I’m pretty certain that this affects AS 2.3 as well. I don’t know the version of IntelliJ it’s built against, but I’m fairly certain that it’s not a 2017 build.

So for the time being, I’m afraid you either need to update your AS to a more recent version, or wait until the next stable build & use the Gradle task for unit tests until then…

1reaction
ivanschuetzcommented, Jun 13, 2017

After reading this, I added this to my dependencies:

compile "org.junit.platform:junit-platform-launcher:1.0.0-M4"

But now I get:

Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform.engine.discovery.DiscoverySelectors.selectNames(Ljava/util/Collection;)Ljava/util/List;
	at com.intellij.junit5.JUnit5TestRunnerUtil.buildRequest(JUnit5TestRunnerUtil.java:75)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:39)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

According to https://github.com/junit-team/junit5/issues/586 this is related with using an incompatible launcher version…? But it passed Gradle check at least, I tried first with M3 and Gradle didn’t let me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Running JUnit tests in IntelliJ, getting: java.lang ...
Running JUnit tests in IntelliJ, getting: java.lang.NoSuchMethodError: org.junit.platform.commons.util.Preconditions.notNull · Ask Question.
Read more >
Fixing the NoSuchMethodError JUnit Error | Baeldung
Learn how to fix the NoSuchMethodError and NoClassDefFoundError JUnit errors.
Read more >
JUnit 5 User Guide
The JUnit Platform serves as a foundation for launching testing ... assertEquals; import example.util. ... RetentionPolicy; import java.lang.annotation.
Read more >
junit-team/junit5 - Gitter
ClassNotFoundException: org.junit.platform.launcher.core.LauncherFactory at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.
Read more >
org.junit.platform.commons.util.ReflectionUtils Maven / Gradle ...
BOTTOM_UP; import static org.junit.platform.commons.util.ReflectionUtils.HierarchyTraversalMode.TOP_DOWN; import java.io.File; import java.lang.reflect.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found