Assertj softassertions throwing exception

574 Views Asked by At

Assertj soft assertion is throwing exception, its only doing the first assertion and its failing after. any help will be appreciated.

    org.assertj.core.api.SoftAssertionError: 
    The following assertion failed:
    1) 
    Expected size:<8> but was:<7> in:
    <"seleniu">
    at SpringTest.lambda$stringTest$0(SpringTest.java:15)
        at org.assertj.core.api.AbstractSoftAssertions.throwsBestMultipleAssertionsError(AbstractSoftAssertions.java:198)
        at org.assertj.core.api.SoftAssertions.assertAll(SoftAssertions.java:131)
        at org.assertj.core.api.SoftAssertions.assertSoftly(SoftAssertions.java:159)

public class SpringTest {

@Test(dataProvider = "getData")
public void stringTest(String input){

    //Soft assertions.
    assertSoftly(softAssertions -> {
        softAssertions.assertThat(input)
                .hasSize(8)
                .startsWith("se")
                .doesNotContain("api")
                .doesNotContainAnyWhitespaces()
                .containsOnlyOnce("i");
    });

}

@DataProvider
public Object[] getData(){
    return new String[]{
            "seleniu",
            "selenide"
    };
}

}

0

There are 0 best solutions below