【问题标题】:How to run only specific tests with Gradle and JUnit 5?如何使用 Gradle 和 JUnit 5 仅运行特定测试?
【发布时间】:2018-07-20 08:41:15
【问题描述】:

使用 Gradle 及其对 JUnit 4 的支持,我可以使用 --tests 选项选择特定测试,如下所示:

$ ./gradlew test --tests de.mp.BarMT

此选项在使用 JUnit 5 Gradle 任务时无效。从命令行使用 test 任务时,它会被静默忽略。反正真正的工作是junitPlatformTest做的,不支持选项:

$ ./gradlew clean junitPlatformTest --tests de.mp.BarMT
…
Problem configuring task :junitPlatformTest from command line.
> Unknown command-line option '--tests'.

JUnit 5 插件是否支持选择特定测试?

【问题讨论】:

标签: gradle junit5


【解决方案1】:

回答自己... 很多时间过去了,新版本来了,我可以用 Gradle 5.4.1 和 JUnit Jupiter Platform 1.4.2 确认,简单的配置:

test {
    useJUnitPlatform()
}

将允许运行 https://stackoverflow.com/a/31468902/2621917 中所见的单个测试,即使使用奇怪的名称(来自 Kotlin):

gradle test --tests 'HtmlForwardInterceptorTest.should forward requests'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-09
    • 2015-01-31
    • 2016-03-13
    • 2017-03-28
    • 2018-07-26
    • 2018-06-11
    • 2018-08-19
    • 1970-01-01
    相关资源
    最近更新 更多