[英]How to check that frame does not contain jlabel with specific text with help of Assertj?
我想用 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.");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.