2017-03-27 3 views

답변

1

원하는만큼 그룹을 추가 할 수 있습니다. :

Before Group 
first 
second 
four 

설명 : 당신은 단지 테스트 케이스 을 실행할 때

Before Group 
first 
second 
third 
four 
five 
Before Group 
Six 

출력 : 첫째 종속 테스트를 실행 당신이 스위트로 실행

package com.stack.JarCreation; 

import org.testng.annotations.BeforeGroups; 
import org.testng.annotations.Test; 

public class TestNgGroups { 

    @BeforeGroups({"gp","group"}) 
    public void beforeGroup(){ 
     System.out.println("Before Group"); 
    } 

    @Test(priority=1,groups="gp") 
    public void first(){ 
     System.out.println("first"); 
    } 

    @Test(priority=2,groups="gp") 
    public void second(){ 
     System.out.println("second"); 
    } 

    @Test(priority=3) 
    public void third(){ 
     System.out.println("third"); 
    } 
    @Test(priority=4,dependsOnGroups="gp") 
    public void four(){ 
     System.out.println("four"); 
    } 
    @Test(priority=5) 
    public void five(){ 
     System.out.println("five"); 
    } 
    @Test(priority=6,groups="group") 
    public void Six(){ 
     System.out.println("Six"); 
    } 

} 

출력 그런 다음이 테스트 사례를 마침내 실행합니다. 테스트 케이스 중 하나라도 실패하면이 테스트 케이스는 건너 뜁니다.

희망이 도움이 될 것입니다.