Gradle 4.6 + Junit 5:`-Dtest.single`不起作用?

时间:2018-03-28 17:13:38

标签: gradle junit5

使用Gradle 4.6,我制作了一个超级简单的测试项目来测试JUnit 5的兼容性。 putfirst(df, df.index.get_loc('soma')) DATA_BASE UF COD MUN CNPJ soma 1196442.0 NaN 66325.0 NaN 21159287.0 0 199407.0 AC 1030.0 MANCIO LIMA 4064077.0 1 199407.0 AC 5184.0 MANOEL URBANO 4064077.0 2 199407.0 AC 9465.0 ASSIS BRASIL 4064077.0 3 199407.0 AC 15978.0 FEIJO 4064077.0 4 199407.0 AC 15978.0 FEIJO 4902979.0 5 199407.0 AC 18690.0 XAPURI 0.0 似乎不起作用。我已经浏览了文档,我想运行一个测试类和/或单个测试方法。在这里,我期待

-Dtest.single

我有一个故意失败的测试用例名为 gradle clean -Dtest.single=junittest.SampleTests test FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':test'. > Could not find matching test for pattern: junittest.SampleTests

failingTest()

我的build.gradle:

gradle clean test

> Task :test FAILED

junittest.SampleTests > failingTest() FAILED
    org.opentest4j.AssertionFailedError at SampleTests.java:16

1 个答案:

答案 0 :(得分:4)

根据documentationtest.single选项基于文件名模式,即当您将.替换为/时,它可以正常运行:

./gradlew clean test -Dtest.single=junittest/SampleTests

但是,在大多数情况下,使用--tests选项更容易:

./gradlew clean test --tests junittest.SampleTests