无法使用JUnit5控制台启动器运行测试 [英] Unable to run tests with JUnit5 Console Launcher

查看:2272
本文介绍了无法使用JUnit5控制台启动器运行测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

给我一​​个警告

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 .

结果是这样的:

. +-JUnit木星[确定]
'-JUnit Vintage [确定]

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

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

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 ]

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

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

这是我的测试课:

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

import org.junit.jupiter.api.Test;

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

import static org.junit.jupiter.api.Assertions.assertEquals;

AFirstTest类{

class AFirstTest {

@Test
void helloJUnit5() {
    assertEquals(2, 3 - 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

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

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

这篇关于无法使用JUnit5控制台启动器运行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆