2017-03-08 128 views

回答

2

您可以使用標準JUnit註釋。

在類似這樣的亞軍類寫點東西:

@RunWith(Cucumber.class) 
@Cucumber.Options(format = {"html:target/cucumber-html-report", "json-pretty:target/cucumber-json-report.json"}) 
public class RunCukesTest { 

    @BeforeClass 
    public static void setup() { 
     System.out.println("Ran the before"); 
    } 

    @AfterClass 
    public static void teardown() { 
     System.out.println("Ran the after"); 
    } 
} 
1

使用TestNG套件的功能將正常工作。

@BeforeSuite 
public static void setup() { 
    System.out.println("Ran once the before all the tests"); 
} 

@AfterSuite 
public static void cleanup() { 
    System.out.println("Ran once the after all the tests"); 
} 
-1

黃瓜的情景基礎測試,您應該一步寫自己的場景.feature文件的步驟和這些步驟是由他們的步驟定義分別執行。

所以如果你想要在所有步驟之後發生一些事情,你應該在最後一步寫出它,並在步驟定義中開發這一步驟。

另外,對於您想要在執行其他步驟之前要執行的操作,您應該在.feature文件中的所有步驟之前考慮一個步驟,並在其步驟定義中對其進行開發。