仅Gradle + TestNG运行指定的组 [英] Gradle + TestNG Only Running Specified Group

查看:174
本文介绍了仅Gradle + TestNG运行指定的组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试通过将测试分组到不同区域来重组非常大的测试库.到目前为止,我所做的是在TestNG中创建一个"api-crud"组,并相应地设置@Test参数.

Trying to reorganize a very large library of tests by grouping them into different areas. What I've done so far is create a "api-crud" group within TestNG and setting the @Test parameters accordingly.

我该如何仅运行这些测试?当我尝试执行以下操作时:

How can I, in gradle, run only these tests? When I try to do the following:

includeGroups 'api-crud'

gradle似乎仍然可以运行所有内容.

gradle seems to run everything still.

我已经看到一些设置excludeGroups的示例,但是由于项目的规模和范围,目前这是不现实的.

I've seen some of the examples of setting excludeGroups, but that is currently unrealistic due to the size and scope of the project.

推荐答案

includeGroups对我有用.尝试运行 gradle clean test -i .这是我测试过的东西:

includeGroups worked for me. Try running gradle clean test -i. Here is what I tested with:

src/main/java/Greeter.java:

public class Greeter {..}

src/test/java/GreeterTest.java:

public class GreeterTest {

    private Greeter greeter = new Greeter();

    @Test(groups = ("simple"))
    public void sayHi_default() {..}

    @Test(groups = ("personalized"))
    public void sayHi_with_args() {..}
}

build.gradle:

apply plugin: 'java'

sourceCompatibility = 1.7
version = '1.0'

repositories {
    mavenCentral()
}

dependencies {
    testCompile 'org.testng:testng:6.8.21'
}

test {
    useTestNG() {
        includeGroups 'simple'
    }
}

这篇关于仅Gradle + TestNG运行指定的组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆