2017-03-27 1 views

Antwort

1

Sie können beliebig viele Gruppen hinzufügen. :

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"); 
    } 

} 

Ausgang, wenn Sie es als Suite laufen:

Before Group 
first 
second 
four 

Erläuterung:

Before Group 
first 
second 
third 
four 
five 
Before Group 
Six 

Ausgabe, wenn Sie nur Testfall vier laufen Zuerst wird es abhängig Testlauf Fälle, dann wird es diesen Testfall endlich ausführen. Wenn einer der Testfälle fehlschlägt, wird dieser Testfall übersprungen.

Hoffe, das wird helfen.

Verwandte Themen