java - JUnit5 控制台启动器在提供的类路径中找不到任何测试
问题描述
我已经下载了 JUnit 5 控制台启动器的独立 jar,但我无法使其与我的代码一起使用。
给定 file/pkg 结构src/test/java/com/fteotini/dummy/SubjectTest.java
和以下测试类:
package com.fteotini.dummy;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class SubjectTest {
@Test
void it_runs() {
assertTrue(true);
}
}
运行时
java -jar junit-platform-console-standalone-1.5.1.jar -cp ./target/test-classes/com/fteotini/dummy --scan-classpath
它没有找到任何测试
Test run finished after 42 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 ]
解决方案
类路径错误。在您的情况下,它应该如下所示:
-cp ./target/test-classes
推荐阅读
- azure - Azure Synapse Studio ServerLess SQL 池访问错误
- javascript - 在 Apache Echarts 中获取值而不是 dataZoom 的百分比
- oracle - 来自共享组件 LOV 的 Oracle 顶点填写表单
- sql - Oracle Apex - 选择不同时间的日期
- apache - .htacess 从文件夹重写会破坏网站
- eclipse - 如何以编程方式(或从 XML)添加外部运行配置
- arrays - 在数组中计算反函数的问题
- html - 对齐 Bootstrap 手风琴头
- html - VBScript 从 HTML 转换为 DOCX 保存损坏的文件,
- javascript - 如何以较小的音频片段发送用户提供的音频文件,以便在 js 中的服务器上处理