ant - Ant junitlauncher 任务不运行测试
问题描述
我有一个 ant 目标可以通过以下方式运行 junit5 测试junitlauncher
:
<target name="juint" depends="build">
<mkdir dir="${junit.output.dir}" />
<junitlauncher haltOnFailure="true" printSummary="true">
<!-- include the app code & libraries required to run the tests -->
<classpath>
<path refid="datastudio-trunk-java-lib.classpath" />
<pathelement location="target/classes"/>
</classpath>
<classpath>
<!-- the test classes themselves -->
<pathelement location="target/test-classes"/>
</classpath>
<testclasses outputdir="${junit.output.dir}">
<fileset dir="target/test-classes">
<include name="**/*.class"/>
</fileset>
<listener type="legacy-brief" sendSysOut="true"/>
<listener type="legacy-xml" sendSysErr="true" sendSysOut="true"/>
</testclasses>
</junitlauncher>
</target>
正如我们在输出中看到的那样,该任务找到了我的测试,但没有运行它们:
[junitlauncher] Test run finished after 31 ms
[junitlauncher] [ 2 containers found ]
[junitlauncher] [ 0 containers skipped ]
[junitlauncher] [ 0 containers started ]
[junitlauncher] [ 0 containers aborted ]
[junitlauncher] [ 0 containers successful ]
[junitlauncher] [ 0 containers failed ]
[junitlauncher] [ 5 tests found ]
[junitlauncher] [ 0 tests skipped ]
[junitlauncher] [ 0 tests started ]
[junitlauncher] [ 0 tests aborted ]
[junitlauncher] [ 0 tests successful ]
[junitlauncher] [ 0 tests failed ]
我有一个简单的 junit 测试类,它定义了 5 个这样的测试:
@RunWith(JUnitPlatform.class)
class JDBC {
private static Logger log = null;
@BeforeAll
public static void setLogger() throws MalformedURLException {
System.setProperty("log4j.configurationFile", "../log4j2.xml");
log = LogManager.getLogger("fr.data.datastudio.test");
log.info("logging enabled");
}
// [...]
@Test
void testSqlite() {
Jdbc4Jni db = connect("org.sqlite.JDBC", "jdbc:sqlite::memory:", null, null);
_testTypes(db);
}
}
测试在 eclipse Junit 视图中运行正常,但不是从 ant。有谁知道为什么他们被发现但没有开始(也没有跳过)?
解决方案
推荐阅读
- swiftui - SDWebImage(SwiftUI) imageThumbnailPixelSize 和缓存行为
- kubernetes - 流量不会进入 hpa kubernetes 中新复制的 pod
- php - PHP登录系统验证问题
- pytorch - 在 SageMaker 的训练脚本中调用 PyTorch Estimator 超参数
- javascript - 在 webpack 中处理具有大量全局函数的大型 JS 文件
- python - 是否可以在收集之后但在 setuptools 中打包之前执行额外的命令?
- sql - 如何在 PostgreSQL 中基于 order by 字段获得第二高到最低值的记录
- php - PHP MongoDB 驱动程序在运行任何 php 命令时显示错误(所有版本在 1.8.0beta1 之后发布)
- java - keytool error: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.8.0_221\jre\lib\security\cacerts(系统找不到指定的路径)
- aws-lambda - AWS Lambda 重试次数超过最大重试次数