Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

java - Unable to run tests with JUnit5 Console Launcher

I am trying to run a simple test with the JUnit5 console launcher. I tried several options, but it does not work. Can somebody tell me what goes wrong?

java -jar .junit-platform-console-standalone-1.0.0-RC3.jar -c AFirstTest.class

java -jar .junit-platform-console-standalone-1.0.0-RC3.jar -c AFirstTest

gives me a warning

WARNUNG: TestEngine with ID 'junit-jupiter' failed to discover tests

I tried to run all tests in the directory, but this does not seem to find the test:

java -jar .junit-platform-console-standalone-1.0.0-RC3.jar -d .

The result is this:

. +-- JUnit Jupiter [OK]
'-- JUnit Vintage [OK]

Test run finished after 11 ms [ 2 containers found ]
[ 0 containers skipped ] [ 2 containers started ]
[ 0 containers aborted ] [ 2 containers successful ]
[ 0 containers failed ] [ 0 tests found ]
[ 0 tests skipped ] [ 0 tests started ]
[ 0 tests aborted ] [ 0 tests successful ]
[ 0 tests failed ]

I am on Windows 10, and I was successful in running the tests from IntelliJ.

This is my test class:

import org.junit.jupiter.api.Test;
 
import static org.junit.jupiter.api.Assertions.assertEquals;
 
class AFirstTest {
 
    @Test
    void helloJUnit5() {
        assertEquals(2, 3 - 1);
    }

}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You have to include the current directory in your classpath. Like:

java -jar junit-platform-console-standalone-1.5.2.jar --class-path . -c AFirstTest

It should work without including it. I think. Would you mind raising an issue at https://github.com/junit-team/junit5/issues ?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...