我有一个断言,用于检查当前所选文本中是否存在字符串:
import static org.junit.Assert.assertThat;
import static org.hamcrest.Matchers.containsString;
assertThat(latest.getText(), containsString(targetString));
Run Code Online (Sandbox Code Playgroud)
但我找不到正确的方法来编写断言来检查文本中是否不包含字符串。
我试过
assertThat(latest.getText(), not(containsString(targetString)));
Run Code Online (Sandbox Code Playgroud)
但出现错误
the method not(Matcher <String>) is undefined
Run Code Online (Sandbox Code Playgroud)
有什么方法可以做到这一点?