首页 文章

无法使用JUnit5 Console Launcher运行测试

提问于
浏览
2

我试图用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

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

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

结果是这样的:

. - JUnit Jupiter [OK]' - JUnit Vintage [OK]测试运行11 ms后结束[发现2个容器] [0个容器已跳过] [2个容器已启动] [0个容器已中止] [2个容器成功] [0个容器失败] [0测试发现] [0测试跳过] [0测试开始] [0测试中止] [0测试成功] [0测试失败]

我在Windows 10上,我成功地运行了IntelliJ的测试 .

这是我的测试类:

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

1 回答

  • 0

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

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

    没有它,它应该工作,包括它 . 我认为 . 你介意在https://github.com/junit-team/junit5/issues提出问题吗?

相关问题