无法使用JUnit5控制台启动器运行测试

Ann*_*nna 5 java junit5

我正在尝试使用JUnit5控制台启动器运行一个简单的测试。我尝试了几种选择,但没有用。有人可以告诉我哪里出了问题吗?

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

给我警告

WARNUNG: TestEngine with ID 'junit-jupiter' failed to discover tests
Run Code Online (Sandbox Code Playgroud)

我试图在目录中运行所有测试,但这似乎找不到测试:

java -jar .\junit-platform-console-standalone-1.0.0-RC3.jar -d .
Run Code Online (Sandbox Code Playgroud)

结果是这样的:

。+-JUnit Jupiter [确定]
'-JUnit Vintage [确定]

11毫秒后测试运行完成[找到2个容器]
[跳过0个容器]
[0个容器中止] [0个容器成功]
[0个容器失败] [找到0个测试]
[0个测试被跳过] [0个测试开始]
[0测试中止] [0测试成功]
[0测试失败]

我在Windows 10上,并且成功运行了IntelliJ的测试。

这是我的测试课:

导入org.junit.jupiter.api.Test;

导入静态org.junit.jupiter.api.Assertions.assertEquals;

AFirstTest类{

@Test
void helloJUnit5() {
    assertEquals(2, 3 - 1);
}
Run Code Online (Sandbox Code Playgroud)

}

Sor*_*ras 6

您必须将当前目录包含在类路径中。喜欢:

java -jar junit-platform-console-standalone-1.5.2.jar --class-path . -c AFirstTest
Run Code Online (Sandbox Code Playgroud)

它应该可以在不包含它的情况下工作。我认为。您介意在https://github.com/junit-team/junit5/issues提出问题吗?