当非顺序优先级时,TestNG优先级注释不起作用

问题描述 投票:0回答:1

我在TestNG中的优先级注释没有运行测试用例时遇到一些问题。我的优先级数字不是顺序的,我故意跳过数字,因此在将来的日期我可以在它们之间添加一些测试方法,以便按特定顺序运行。任何想法如何让TestNG执行我的测试方法遵循数字差距?例如,我的优先顺序为1 - 3,然后我跳转到200 - 202.优先级为200 - 202的测试没有执行。谢谢你的时间。

public class ClassOneTest{
    @Test (enabled=true, priority=1)
    public void methodOneTest() {
        .....
    }

    /**
     * Updates the ServiceNow End Point
     */
    @Test (enabled=true, priority=2)
    public void methodTwoTest() {
        .....
    }

    /**
     * Deletes the ServiceNow End Point
     */
    @Test (enabled=true, priority=3)
    public void methodTwoTest() {
        .....
    }
}

public class ClassTwoTest{
    @Test (enabled=true, priority=200)
    public void methodThreeTest() {
        .....
    }

    /**
     * Updates the ServiceNow End Point
     */
    @Test (enabled=true, priority=201)
    public void methodFourTest() {
        .....
    }

    /**
     * Deletes the ServiceNow End Point
     */
    @Test (enabled=true, priority=202)
    public void methodFiveTest() {
        .....
    }
}
testing annotations testng
1个回答
0
投票

我发现了这个问题。在具有较低优先级的课程之前,具有200年代优先级的类被加载到套件中。一旦我改变了加载顺序,它就可以了。

© www.soinside.com 2019 - 2024. All rights reserved.