2013-06-24 39 views
0

請檢查下面的代碼,我執行這個特殊的代碼,但得到輸出 了URL 測試場景 已註銷 登錄。獲取輸出錯誤TestNG中

But as per priority given output should be different. 
Kindly look into it and help me on this. 

public class DependencyAnnotation { 
    @Test(groups={"PreCondition"},priority=0) 
    public void getURL(){ 
     System.out.println("Got URL"); 
    } 

    @Test(priority=1,dependsOnGroups={"PreCondition"}) 
    public void login() { 
     System.out.println("Logged In"); 
    } 

    @Test(priority=2) 
    public void testScenario(){ 
     System.out.println("Testing Scenario"); 
    } 

    @Test(priority=3) 
    public void logout(){ 
     System.out.println("Logged Out"); 
    } 
} 

回答

0

getURL()login()形式依賴性的鏈; testScenario()logout()不。 They fall into different schedules

顯然,在每個組的範圍內應用優先級。

因此,這種佈局不符合您的期望。

作爲一種姑息,試着製作testScenario()logout()也取決於getURL()

也請考慮使用涉及使用@Before*@After*宣傳方法的模型。