1

I am trying to run this file, a test class I wrote for one of my classes.

when I try to run this via IntelliJ Idea, I get no java.lang.nosuchmethoderror, and it won't run the tests for me, it will find no test methods.

the errors are:

Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform.commons.util.ReflectionUtils.getDefaultClassLoader()Ljava/lang/ClassLoader;
    at org.junit.platform.launcher.core.ServiceLoaderTestEngineRegistry.loadTestEngines(ServiceLoaderTestEngineRegistry.java:30)
    at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:53)
    at com.intellij.junit5.JUnit5IdeaTestRunner.createListeners(JUnit5IdeaTestRunner.java:39)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:49)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

and this is my test class: https://pastebin.com/FMTwu3Rd

I think there are some IntelliJ Idea setting errors, but I can't seem to find it. BTW the tests are run with JUnit 4.

Thank you in advance!

Stefan Birkner
  • 24,059
  • 12
  • 57
  • 72
S. N
  • 3,456
  • 12
  • 42
  • 65
  • Have tried by doing clean and build? – Bikramjit Rajbongshi Nov 03 '17 at 10:02
  • 1
    this is not a IntelliJ issue, this is what happens if you pas the wrong type of argument, or call a method that doesn't exist – Stultuske Nov 03 '17 at 10:02
  • @BikramjitRajbongshi I am not sure how that works, I am new to IntelliJ Idea. can you maybe help? – S. N Nov 03 '17 at 10:03
  • not sure, but test methods without a test in it might indeed lead to trouble. @Test public void getHighScoreTableTopX() throws Exception { } – Stultuske Nov 03 '17 at 10:03
  • Are you sure that the JUnit version is correct? `JUnit5IdeaTestRunner.java` suggest JUnit 5 and not 4, and maybe that's the problem. – xander Nov 03 '17 at 10:07
  • https://stackoverflow.com/questions/43003012/class-javalaunchhelper-is-implemented-in-two-places/43003231#43003231 view this – Sviatlana Nov 03 '17 at 10:41
  • This is an IntelliJ IDEA issue. You resolve the issue by defining all the dependencies (Maven project). This question has been answered [here on StackOverflow](https://stackoverflow.com/questions/46384624/java-lang-nosuchmethoderror-when-run-test-with-junit-5). – Osmund Francis Nov 18 '17 at 20:41

0 Answers0