I want to test my simple application with AssertJ. I can check that text is showing like that:
frame.label(JLabelMatcher.withText(text).andShowing());
But is there any way to check that specific text not showing?
As a result, I solved this issue in such a not pretty way:
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.");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.