IDEA fails to run Junit5 with 'junit-jupiter' error
Answered
Hi.
I have a project with JUnit5 tests in separate package. At first all tests worked fine.
Today I cloned the code from github to another computer with IDEA, and the tests were not detected with the error described below.
I don't remember what I changed in the original IDEA, but even there I get the same error.
I checked all forums and topics all the day, added and removed libraries from project, and nothing has changed.
I've seen a lot of talk about Maven's file, but I don't have one, so I wrote the iml file.
OS: Ubuntu 17.10, Windows 10
IDE in ubuntu:
IntelliJ IDEA 2018.1 (Ultimate Edition)
Build #IU-181.4203.550, built on March 26, 2018
JRE: 1.8.0_152-release-1136-b20 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.13.0-39-generic
Log file:
2018-04-10 20:54:31,729 [ 423336] INFO - ij.compiler.impl.CompileDriver - COMPILATION STARTED (BUILD PROCESS)
2018-04-10 20:54:31,738 [ 423345] INFO - j.compiler.server.BuildManager - Using preloaded build process to compile /home/baruch/IdeaProjects/commpress-assig1
2018-04-10 20:54:31,862 [ 423469] INFO - lij.compiler.impl.CompilerUtil - COMPILATION FINISHED (BUILD PROCESS); Errors: 0; warnings: 0 took 139 ms: 0 min 0sec
2018-04-10 20:54:31,864 [ 423471] INFO - s.CompilerReferenceServiceImpl - backward reference index reader is opened
2018-04-10 20:54:33,325 [ 424932] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stdout]: Build process started. Classpath: /home/baruch/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/181.4203.550/lib/jps-launcher.jar:/opt/jdk-9.0.4/lib/tools.jar:/home/baruch/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/181.4203.550/lib/optimizedFileManager.jar
2018-04-10 20:54:33,423 [ 425030] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
2018-04-10 20:54:33,423 [ 425030] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Defaulting to no-operation (NOP) logger implementation
2018-04-10 20:54:33,423 [ 425030] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2018-04-10 20:54:33,541 [ 425148] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: An illegal reflective access operation has occurred
2018-04-10 20:54:33,541 [ 425148] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/home/baruch/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/181.4203.550/lib/netty-all-4.1.13.Final.jar) to field sun.nio.ch.SelectorImpl.selectedKeys
2018-04-10 20:54:33,541 [ 425148] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: Please consider reporting this to the maintainers of io.netty.util.internal.ReflectionUtil
2018-04-10 20:54:33,541 [ 425148] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
2018-04-10 20:54:33,541 [ 425148] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: All illegal access operations will be denied in a future release
Error output:
/opt/jdk-9.0.4/bin/java -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:/home/baruch/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/181.4203.550/lib/idea_rt.jar=40241:/home/baruch/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/181.4203.550/bin -Dfile.encoding=UTF-8 -classpath /home/baruch/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/181.4203.550/lib/idea_rt.jar:/home/baruch/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/181.4203.550/plugins/junit/lib/junit-rt.jar:/home/baruch/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/181.4203.550/plugins/junit/lib/junit5-rt.jar:/home/baruch/.m2/repository/org/junit/platform/junit-platform-launcher/1.1.1/junit-platform-launcher-1.1.1.jar:/home/baruch/.m2/repository/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.jar:/home/baruch/.m2/repository/org/junit/platform/junit-platform-engine/1.1.1/junit-platform-engine-1.1.1.jar:/home/baruch/.m2/repository/org/junit/platform/junit-platform-commons/1.1.1/junit-platform-commons-1.1.1.jar:/home/baruch/.m2/repository/org/opentest4j/opentest4j/1.0.0/opentest4j-1.0.0.jar:/home/baruch/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.1.1/junit-jupiter-engine-5.1.1.jar:/home/baruch/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.1.1/junit-jupiter-api-5.1.1.jar com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit5 test.UtilsTest
Apr 10, 2018 8:54:32 PM org.junit.platform.launcher.core.DefaultLauncher handleThrowable
WARNING: TestEngine with ID 'junit-jupiter' failed to discover tests
org.junit.platform.commons.util.PreconditionViolationException: Could not load class with name: test.UtilsTest
at org.junit.platform.engine.discovery.ClassSelector.lambda$getJavaClass$0(ClassSelector.java:71)
at java.base/java.util.Optional.orElseThrow(Optional.java:385)
at org.junit.platform.engine.discovery.ClassSelector.getJavaClass(ClassSelector.java:70)
at org.junit.jupiter.engine.discovery.DiscoverySelectorResolver.lambda$resolve$3(DiscoverySelectorResolver.java:69)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1380)
at org.junit.jupiter.engine.discovery.DiscoverySelectorResolver.resolve(DiscoverySelectorResolver.java:68)
at org.junit.jupiter.engine.discovery.DiscoverySelectorResolver.resolveSelectors(DiscoverySelectorResolver.java:50)
at org.junit.jupiter.engine.JupiterTestEngine.discover(JupiterTestEngine.java:61)
at org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(DefaultLauncher.java:130)
at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:117)
at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:82)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:52)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Apr 10, 2018 8:54:33 PM org.junit.platform.launcher.core.DefaultLauncher handleThrowable
WARNING: TestEngine with ID 'junit-jupiter' failed to discover tests
org.junit.platform.commons.util.PreconditionViolationException: Could not load class with name: test.UtilsTest
at org.junit.platform.engine.discovery.ClassSelector.lambda$getJavaClass$0(ClassSelector.java:71)
at java.base/java.util.Optional.orElseThrow(Optional.java:385)
at org.junit.platform.engine.discovery.ClassSelector.getJavaClass(ClassSelector.java:70)
at org.junit.jupiter.engine.discovery.DiscoverySelectorResolver.lambda$resolve$3(DiscoverySelectorResolver.java:69)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1380)
at org.junit.jupiter.engine.discovery.DiscoverySelectorResolver.resolve(DiscoverySelectorResolver.java:68)
at org.junit.jupiter.engine.discovery.DiscoverySelectorResolver.resolveSelectors(DiscoverySelectorResolver.java:50)
at org.junit.jupiter.engine.JupiterTestEngine.discover(JupiterTestEngine.java:61)
at org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(DefaultLauncher.java:130)
at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:117)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Process finished with exit code 0
Empty test suite.
Download Library from Maven repositories:
org.junit.jupiter:junit-jupiter-api:5.0.0
MyProject.iml:
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="JUnit5.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.0.0/junit-jupiter-api-5.0.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.0.0/opentest4j-1.0.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.0.0/junit-platform-commons-1.0.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
Please sign in to leave a comment.
Please report at https://youtrack.jetbrains.com/issues/IDEA with the sample project to reproduce attached.
OK, I found the problem.
The problem was in the misc.xml file in a row:
<output url="file://out" />
That should be:
<output url="file://$PROJECT_DIR$/out" />
My mistake was that I didn't try to reproduce before I searched and asked.