gpt4 book ai didi

java - 断言字符串列表包含忽略大小写的字符串

转载 作者:行者123 更新时间:2023-12-03 23:57:23 25 4
gpt4 key购买 nike

我正在使用 Hamcrest 匹配器来断言字符串列表包含一个字符串,忽略大小写。我的代码如下:

assertThat("myList has the string", myList, Matchers.hasItem(Matchers.equalToIgnoringCase(string)));

但是我的 java 编译器提示这一行:

cannot find symbol
[ERROR] symbol : method assertThat(java.lang.String,java.util.List<java.lang.String>,org.hamcrest.Matcher<java.lang.Iterable<? super java.lang.Object>>)

谁能帮我解决这个错误?

谢谢。

最佳答案

使用 equalToIgnoringCase :

assertThat("Has potential promotion", b2BCartPage.getPromotionTexts(), hasItem(equalToIgnoringCase(messages.getString("cart.promotion.attention"))));

关于java - 断言字符串列表包含忽略大小写的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42565918/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com