如何在 Assertj 的帮助下检查框架不包含带有特定文本的 jlabel?



我想用 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.");
}

最新更新