微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

断言软断言抛出异常

如何解决断言软断言抛出异常

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 举报,一经查实,本站将立刻删除。