我有一个目标,可以通过junitlauncher
运行junit5测试:
<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运行。有谁知道为什么找到了它们但没有开始(也没有跳过)?