Reputation: 314
I am using Junit4.
This is my test class:
import org.junit.Test;
public class UIUtilTest {
@Test
public void testMultiline() {
var multiLineText = "one\ntwo";
UIUtil.showError(multiLineText, "title");
assert true;
}
}
I have the following Jacoco coverage result:
How can I test the lambda that Jacoco is complaining about in order to hit 100% coverage?
Upvotes: 0
Views: 149
Reputation: 32550
Make test wait for dialog to pop. Having your implementation you can simply add another task to the EDT queue and wait for it to finish.
@Test
public void testMultiline() throws InterruptedException, InvocationTargetException {
String multiLineText = "one\ntwo";
UIUtil.showError(multiLineText, "title");
SwingUtilities.invokeAndWait(() -> {
//just wait, nothing more
});
assert true;
}
Upvotes: 0