tosha tosha - 7 months ago 44
Java Question

Cucumber-JUnit, is there a way to control the order in which @before and @after tags run

I have two @after tags, @close-browser and @screenshot.So, right now when I use both tags for feature file it is first executing @close-browser and It fails in executing after method for @screenshot.
Is there a way that I can tell cucumber to run @screenshot after method first?


The screenshot should be taken in one of the @After annotated methods. Like this:

public void finish(Scenario scenario) {
    try {
        byte[] screenshot =
        scenario.embed(screenshot, "image/png");
    } catch (WebDriverException somePlatformsDontSupportScreenshots) {

    finally {