Jacobvu84 / Automated-Software-Testing

Nơi lữu trữ các vấn đề được trao đổi bởi cộng đồng Automated Software Testing
2 stars 4 forks source link

Lấy TestOutcome #42

Open Jacobvu84 opened 3 years ago

Jacobvu84 commented 3 years ago

Cách 1:

    public TestOutcome getLastOutcome() {
        return StepEventBus.getEventBus().getBaseStepListener().latestTestOutcome().get();
    }
Jacobvu84 commented 3 years ago

Cách 2: The AfterAWebdriverScenario is called at the end of a test, just before the driver is closed, and once the result of the test is known. The test result (and other details) can be obtained from the TestOutcome parameter. This allows any last manipulations or checks to be performed on the driver, before the end of the test. The following example checks the result of the test that has just finished, and adds a cookie with a value depending on the test outcome:

public class MyTestResultUpdater implements AfterAWebdriverScenario {
    void apply(EnvironmentVariables environmentVariables,
               TestOutcome testOutcome,
               WebDriver driver) {

       final Logger LOGGER = LoggerFactory.getLogger(MyTestResultUpdater.class);

       LOGGER.info("===>" + testOutcome.getTestCaseName());

    }
}

https://serenity-bdd.github.io/theserenitybook/latest/extending-webdriver.html#_the_afterawebdriverscenario_interface