2016-02-05 72 views
0

我用TestNG +的webdriver我的自动化项目,但测试执行的顺序按预期指定为下面的每个方法的顺序不工作与序列运行的是方法签名和记号试验方法不TestNG中

@Test(dependsOnMethods="verifyElementsOnProfileScreen",alwaysRun = true) 
    public void verifyMySelfProfileVisibility(){ 

TestSuit我已使用:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> 
<suite name="regressionSuite" parallel="none"> 

    <parameter name="ApplicationOpt" value="web"></parameter> 
    <parameter name="Browser" value="firefox"></parameter> 

    <test name="Test">  
    <classes> 
     <!-- Login Module --> 
     <class name="Tests.Login.LoginApp"/> 
     <method> 
      <include name ="loginUser"></include> 
     </method> 

     <!-- Portal Module --> 
     <class name="Tests.Profile.ProfileModule"> 
      <method> 
       <include name="verifyElementsOnProfileScreen"></include> 
       <include name="verifyMySelfProfileVisibility"></include> 
      </method> 
     </class> 
     <class name="Tests.Profile.participantAuditLog"> 
     <method> 
      <include name="verifyAuditLogForCreateProfileEvent"></include> 
      <include name="verifyAuditLogForUpdateContactInfoEvnet"></include> 
      <include name="verifyAuditLogForUpdatePrivacyDirective"></include> 
     </method> 
    </class> 

    </classes> 
    </test> <!-- Test --> 
</suite> <!-- regressionSuite --> 

回答

2

你的意思是这的testng.xml文件中指定的特定顺序不执行类..那么请使用保护级=“真”

<suite name="MySuite" preserve-order= "true"> 
<test name="MyTest"> 

如果你想在类指定方法的执行顺序,然后优先使用

@Test(priority = 1) 

组按实例=“真”,如果你面对喜欢的不同优先级类别的方法执行顺序的情况也有用并不如预期..

<suite thread-count="2" verbose="10" name="testSuite" parallel="tests"> 
<test verbose="2" name="MytestCase" group-by-instances="true"> 

谢谢你, 穆拉利