Код: Выделить всё
finder.find()
catch ing componentlookupexception s чувствует себя неправильно (как и любая try/catch с участием Runtimeexception s)
java 8.
import org.fest.swing.core.BasicComponentFinder;
import org.fest.swing.core.ComponentFinder;
import org.fest.swing.core.GenericTypeMatcher;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import javax.swing.JLabel;
import javax.swing.JPanel;
import static org.junit.jupiter.api.Assertions.assertNull;
public class ComponentFinderTest {
ComponentFinder finder;
@BeforeEach
void setUp() {
finder = BasicComponentFinder.finderWithCurrentAwtHierarchy();
}
@Test
public void testFind() throws Exception {
JPanel panel = new JPanel();
// throws org.fest.swing.exception.ComponentLookupException
JLabel label = finder.find(panel, new GenericTypeMatcher(JLabel.class, false) {
@Override
protected boolean isMatching(JLabel component) {
return true;
}
});
assertNull(label);
}
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... -find-call