serenity-bdd / serenity-cucumber-starter

A skeleton project for Serenity BDD and Cucumber JVM
Apache License 2.0
180 stars 285 forks source link

HTML report doesn't generate properly when using soft assert with SerenityBdd+Cucumber #81

Open brianle1995 opened 2 years ago

brianle1995 commented 2 years ago

I have read the article of using soft assert in Serenity Screen Play but it doesn't work with SerenityBdd+Cucumber. How can I get the report with the failed assert in Step as below (http://thucydides.info/docs/articles/soft-asserts.html) without applying Serenity Screen Play: Screen Shot 2022-04-22 at 18 30 36

Below is my source code:

 import org.assertj.core.api.SoftAssertions;

 SoftAssertions soft = new SoftAssertions();

    @Step
    public void verifyGenerateLANResponseAccountLevel(Response response, String expectedAccountLevel) {
        List<String> listAccountLevel = response.jsonPath().getList("luckyAccountInfo.accountLevel");

        listAccountLevel.forEach(item -> {
            soft.assertThat(item).as("Verify account level: ").isEqualTo(expectedAccountLevel);
        });
    }

    @Step
    public void verifyGenerateLANResponseFormat(Response response, String expectedFormat) {
        List<String> listFormat = response.jsonPath().getList("luckyAccountInfo.format");

        listFormat.forEach(item -> {
            soft.assertThat(item).as("Verify format: ").isEqualTo(expectedFormat);
        });
    }

    @After()
    public void afterScenario() {
        listSortAssert.forEach(SoftAssertions::assertAll);
    }

pom.xml

        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-core</artifactId>
            <version>2.0.81</version>
        </dependency>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-cucumber</artifactId>
            <version>1.9.45</version>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>3.6.2</version>
        </dependency>

And the report show SUCCESS in the failed step and all failed assertion in the end of report

Screen Shot 2022-04-23 at 12 51 40