断言软断言抛出异常

问题描述

Assertj 软断言抛出异常,它只执行第一个断言,然后失败。 任何帮助将不胜感激。

    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)

公共类 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"
    };
}

}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)