繁体   English   中英

测试组的TestNG执行顺序

[英]TestNG execution order for test groups

说我有以下XML:

<suite name="MATS">
    <test name="mats_test">
    <groups>
        <run>
            <include name="mats" />
        </run>
    </groups>
    <packages>
        <package name="com.tests" />
    </packages>
    </test>
</suite>

com.tests包中的每个测试类只有一种具有不同组注释的测试方法。 是否将执行beforeClass() afterClass() ”组中的类的beforeClass()afterClass()方法?

除非它们将alwaysRun设置为true否则不在指定组中的Before / After方法将不会运行。

alwaysRun

对于before方法(beforeSuite,beforeTest,beforeTestClass和beforeTestMethod,但不是beforeGroups):如果设置为true,则无论配置文件属于哪个组,都将运行此配置方法。

对于after方法(afterSuite,afterClass,...):如果设置为true,则即使先前调用的一个或多个方法失败或被跳过,此配置方法也将运行。

例如,鉴于以下类别:

public class AMatsTest {
    @BeforeSuite(groups = {"mats"})
    public void beforeSuite() {}
}

public class NotAMatsTest {
    @BeforeSuite
    public void beforeSuite() {}
}

@Test(groups = {"mats"})
public class AnotherMatsTest {
    @BeforeSuite public void beforeSuite() {}
}

public class AlwaysTest {
    @BeforeSuite(alwaysRun = true)
    public void beforeSuite() {}
}

将执行AMatsTest.beforeSuite()AnotherMatsTest.beforeSuite()AlwaysTest.beforeSuite() NotAMatsTest.beforeSuite()将不会执行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM