断言链中的最后断言失败-将所有先前通过的断言显示为失败

问题描述 投票:0回答:1

我有一个包含多个断言的方法,除了最后一个之外,所有方法都在传递,即使传递了它也显示所有的声明消息。是否有人知道如何解决这种情况,我如何仅获得失败消息而不是控制台中的所有消息。

    Assertions.assertThat(actual.getAttribute("id").isEqualTo("first_name");
    Assertions.assertThat(actual.tagName()).isEqualTo("input");
    Assertions.assertThat(actual.getAttribute("class")).isEqualTo("input-group");
    Assertions.assertThat(actual.getText()).isEqualTo("John");

以上是我编写的代码,除最后一个条件外,所有条件都已通过,但如下所示。

Expected actual to be first_name but got <first_name>

Expected actual to be input but got <input>

Expected actual to be input-group but got <input-group>

Expected actual to be Johny but got John

实际上,最后一条语句是失败的,但是即使该条件已通过,它也会显示上述所有消息。

selenium-webdriver automated-tests testng assertj
1个回答
1
投票

如果发布代码示例以重现此问题,您将获得更好的帮助。

您拥有的代码包含错字,因为Assertj提供了isEqualTo,并且您正在使用isEqualsTo

© www.soinside.com 2019 - 2024. All rights reserved.