现在,我遇到了一个问题,那就是找出它在哪个属性上失败了。
目前我正在使用如下所示:
softAssertions.assertThat(resultArrayList)
.extracting("title", "address.countryName", "address.state", "address.city")
.as("Title, CountryName, State, City at position %s", i)
.containsAnyOf(
new Tuple(placeToSearch, expectedCountry, expectedState, expectedCity));
我收到一条失败消息,如下所示
[Title, CountryName, State, City at position 0]
Expecting
<[("DOT Baires Shopping", "Argentina", "Ciudad Autónoma de Buenos Aires", "Ciudad de Buenos Aires")]>
to contain at least one of the following elements:
<[("Dot", "Argentina", "Ciudad Autónoma de Buenos Aires", "Ciudad de Buenos Aires")]>
1)识别/标记失败数据的一些建议。2)有没有办法给失败的人上色
发布于 2019-02-15 20:22:46
在您的示例中,您有一个包含一个元组的列表,这个元组与预期的元组不匹配,因为它们的第一个值不同("Dot"
与"DOT Baires Shopping"
)。元组equals
方法比较所有元组值。
应该可以对实际和预期的列表进行着色,但不能对特定元素进行着色(这是集成开发环境的事情,而不是真正的AssertJ事情)。
以下是几点意见:
为了避免调用new Tuple(...)
,使用带有一个元素的
containsAnyOf(expected)
公开tuple(...)
工厂方法是相同的希望能有所帮助
https://stackoverflow.com/questions/54708442
复制相似问题