我想使用 AssertJ 测试我的简单应用程序。 我可以检查文本是否显示如下:
frame.label(JLabelMatcher.withText(text).andShowing());
但是有什么方法可以检查特定文本是否未显示?
最佳答案
结果,我以一种不太漂亮的方式解决了这个问题:
public void iDontSeeText(String text) {
try {
frame.label(JLabelMatcher.withText(Pattern.compile(".*" + text + ".*", Pattern.CASE_INSENSITIVE)).andShowing());
} catch (Exception e) {
// Control isn't found. Test complete successful
return;
}
// Control is found. Execute exception
throw new RuntimeException("Text \"" + text + "\" is found in frame.");
}
关于java - 如何借助 Assertj 检查该框架不包含带有特定文本的 jlabel?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62134642/