在TestNG中使用DependsOnMethod时出错

问题描述 投票:0回答:1
    @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

怎么解决这个?

testng
1个回答
1
投票

给定代码中有两个问题。

C2410964_PendingBalanceOnHomePageAndMakePaymentPage()依赖于C2410997_FilterPaymentByPending()但是

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

为了让事情奏效,请

  1. 不要使用优先级和dependsOnMethods混合。首选方式是dependsOnMethods。
  2. 设置enabled = true为测试C2410997_FilterPaymentByPending
© www.soinside.com 2019 - 2024. All rights reserved.