Unable to run tests with JUnit5 Console Launcher

早过忘川 提交于 2019-12-10 13:51:45

问题


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);
}

}


回答1:


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 ?



来源:https://stackoverflow.com/questions/45869932/unable-to-run-tests-with-junit5-console-launcher

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!