【问题标题】:Gradle test parameter test suiteGradle 测试参数测试套件
【发布时间】:2013-07-18 12:48:19
【问题描述】:

我是 Gradle 新手。

我的问题:

是否可以根据参数在“Gradle test”中的测试套件之间切换?

类似:

test {
useTestNG()
{
    suites 'src/test/resources/testng-'+input_parameter_as_string+'-Test.xml' 
    useDefaultListeners = true
}

我的目标是调用:gradle test "input_parameter_as_string"。

希望大家能帮帮我。

【问题讨论】:

    标签: gradle build.gradle


    【解决方案1】:

    Gradle 文档列出了一些使用系统属性运行特定测试的方法:http://www.gradle.org/docs/current/userguide/userguide_single.html#sec:java_test。要运行多个相关测试,您可以尝试测试组(TestNG 和 Gradle 都支持):http://testng.org/doc/documentation-main.html#test-groups

    如果您坚持使用自定义闭包,则始终可以使用项目属性。在 build.gradle 中:

    测试 { 使用TestNG() { 套件 'src/test/resources/testng-' + project.ext.input_parameter_as_string +'-Test.xml' useDefaultListeners = true }

    在命令行中:

    gradle 测试 -Pinput_parameter_as_string=testFoobar.

    【讨论】:

    • 谢谢,我会试试的。
    【解决方案2】:

    开箱即用,Gradle 支持运行单个测试:

    ./gradlew test -Dtest.single=MyTestClassName

    【讨论】:

    • 这个只能在你想运行单个测试类的情况下使用,不能用于运行特定的TestNG xml套件!
    猜你喜欢
    • 1970-01-01
    • 2012-05-14
    • 2015-03-09
    • 1970-01-01
    • 2014-01-20
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 2015-01-31
    相关资源
    最近更新 更多