HiI am trying to write a parameterized FEST test. And I encountered a problem: the first run of my test pass successfully, but the second and all next runs fails with stacktrace like this:org.fest.swing.exception.ComponentLookupException: Unable to find component using matcher org.fest.swing.core.TypeMatcher[type=fest_test.GuiForParameterizedTest, requireShowing=true].Component hierarchy:javax.swing.SwingUtilities$SharedOwnerFrame[name='frame1', title='', enabled=true, visible=false, showing=false]at org.fest.swing.core.BasicComponentFinder.componentNotFound(BasicComponentFinder.java:271)at org.fest.swing.core.BasicComponentFinder.find(BasicComponentFinder.java:260)at org.fest.swing.core.BasicComponentFinder.find(BasicComponentFinder.java:179)<...>A similar (or possibly the same) problem appears when I try to create more than one @Test method in the test.As I understood from thread https://groups.google.com/forum/?fromgroups#!searchin/easytesting/Having$20trouble$20running$20multiple$20tests$20together/easytesting/qfMTQINnjmg/QM5vQfnQ4VAJ , a problem like this appers when trying to reuse a window once opened for many separate tests: the window that was initialized before the first test started is inevitably disposed when this test ends, and the second test has nothing to work with. The proposed solution is to run the window initialization and cleanup in the methods annoteded @BeforeClass and @AfterClass correspondingly. But:- in this case I can't access to a Robot instance (@BeforeClass and @AfterClass methods should be static, and robot() method is not), and without it I can' t create a fixture for my application frame- I tried to launch my applicaton separately for each test method run (in onSetUp() method and even in the start of @Test method itself), but the problem persisted: after the try of application launch I received the same stacktrace.What I am doing wrong?Code of sample application:public class GuiForParameterizedTest extends JFrame {
private static final long serialVersionUID = -1484892685385521277L;private static GuiForParameterizedTest instance;private GuiForParameterizedTest() {setSize(100, 100);JTextArea textArea = new JTextArea();textArea.setName("textArea");add(textArea);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setVisible(true);}public static GuiForParameterizedTest getInstance() {if (instance == null) {instance = new GuiForParameterizedTest();}return instance;}public static void main(String[] args) {getInstance();}}Code of parameterized test:
@RunWith(Parameterized.class)public class ParameterizedTest extends FestSwingJUnitTestCase {
private FrameFixture guiWindow;private String text;@Parameterspublic static Collection<String[]> prepareText() {ArrayList<String[]> texts = new ArrayList<String[]>();texts.add(new String[] {"text1"});texts.add(new String[] {"text2"});return texts;}public ParameterizedTest(String text) {this.text = text;}@Overrideprotected void onSetUp() {GuiForParameterizedTest gui = GuiActionRunner.execute(new GuiQuery<GuiForParameterizedTest>() {@Overrideprotected GuiForParameterizedTest executeInEDT() throws Throwable {ApplicationLauncher.application(GuiForParameterizedTest.class).start();GuiForParameterizedTest gui = robot().finder().findByType(GuiForParameterizedTest.class);return gui;}});guiWindow = new FrameFixture(robot(), gui);guiWindow.show();}@Testpublic void checkTextContent() {guiWindow.textBox("textArea").enterText(text);guiWindow.textBox("textArea").requireText(text);}}Code of non-parameterized modification of the same test with the same problem:public class ParameterizedTest extends FestSwingJUnitTestCase {private FrameFixture guiWindow;private String text = "text";@Overrideprotected void onSetUp() {GuiForParameterizedTest gui = GuiActionRunner.execute(new GuiQuery<GuiForParameterizedTest>() {@Overrideprotected GuiForParameterizedTest executeInEDT() throws Throwable {ApplicationLauncher.application(GuiForParameterizedTest.class).start();GuiForParameterizedTest gui = robot().finder().findByType(GuiForParameterizedTest.class);return gui;}});guiWindow = new FrameFixture(robot(), gui);guiWindow.show();}@Testpublic void checkTextContent1() {guiWindow.textBox("textArea").deleteText();guiWindow.textBox("textArea").enterText(text);guiWindow.textBox("textArea").requireText(text);}@Testpublic void checkTextContent2() {guiWindow.textBox("textArea").deleteText();guiWindow.textBox("textArea").enterText(text);guiWindow.textBox("textArea").requireText(text);}}Sorry if the answer is evident - I managed not to find it myself in the project documentation :(And sorry for my poor English. It is not my natural language :)--
You received this message because you are subscribed to the Google Groups "easytesting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to easytesting...@googlegroups.com.
To post to this group, send email to easyt...@googlegroups.com.
Visit this group at http://groups.google.com/group/easytesting?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.