2017-03-08 11 views
2

キュウリ試験のすべてを実行した後にメソッドを実行する方法はありますか?すべてのキュウリ試験後に実行

@Afterアノテーションは個々のテストごとに実行されるでしょうか?私は一度だけ実行するものではなく、最後には何もしませんでした。

答えて

2

標準のJUnitアノテーションを使用できます。あなたのランナークラスの書き込みで

これに似た何か:TestNGのスイート機能付き

@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

も同様に動作します。

@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ファイル内のすべてのステップの前にあるステップを検討し、そのステップ定義で開発する必要があります。

関連する問題