在TestNG中使用DependsOnMethod时出错

时间:2018-09-05 08:43:20

标签: testng

    @Test(priority = 13, enabled = true, dependsOnMethods = {"POM_Test.PaymentsTest.C2410997_FilterPaymentByPending"})
        public void C2410964_PendingBalanceOnHomePageAndMakePaymentPage()
                throws IOException, InterruptedException, ATUTestRecorderException, APIException{
            ///Some Code here.      
        }


@Test(priority = 28, enabled = false)
    public void C2410997_FilterPaymentByPending()
            throws IOException, InterruptedException, ATUTestRecorderException, APIException, AWTException, ParseException {
        //Some dependency is here. 


    }

遇到以下错误,POM_Test.ATransactionTest2.C2410964_PendingBalanceOnHomePageAndMakePaymentPage() is depending on method public void POM_Test.PaymentsTest.C2410997_FilterPaymentByPending() throws java.io.IOException,java.lang.InterruptedException,atu.testrecorder.exceptions.ATUTestRecorderException,com.testrail.connection.APIException,java.awt.AWTException,java.text.ParseException, which is not annotated with @Test or not included

如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

给定的代码中有两个问题。

C2410964_PendingBalanceOnHomePageAndMakePaymentPage()取决于C2410997_FilterPaymentByPending()但

  1. C2410964_PendingBalanceOnHomePageAndMakePaymentPage()具有更高的优先级。
  2. C2410997_FilterPaymentByPending()具有属性enabled = false

为使事情正常进行,请

  1. 请勿混合使用priority和dependsOnMethods。首选方式是dependsOnMethods。
  2. enabled = true设置为测试C2410997_FilterPaymentByPending