how to use WindowTester for multiple junit cases?

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

how to use WindowTester for multiple junit cases?

Postby vcycyv » Tue Apr 01, 2008 6:40 pm

If I have multiple junit test cases, each one ends with ui.close(), how can I add these Junit cases into one TestSuite? Because if the first junit test case calls ui.close(), the the second test case won't start up GUI. Mac says setup(),teardown() may solve this ,but how to? will any one provide an example? My cases are like below:
Demo.java
Code: Select all
public class Demo extends UITestCaseSWT {
   public void testDemo() throws Exception {
      IUIContext ui = getUI();
      ui.click("file/New Contact..."));
      ui.wait(new ShellShowingCondition(""));
      ui.enterText("1");
      ui.keyClick(WT.TAB);
      ui.enterText("2");
      ui.click(new LabeledTextLocator("Street"));
      ui.click(new ButtonLocator("&Finish"));
      ui.close(new SWTWidgetLocator(Shell.class, "RCP Contacts Editor"));
      ui.wait(new ShellDisposedCondition("RCP Contacts Editor"));
         }
}

Demo2.java
Code: Select all
public class Demo2 extends UITestCaseSWT {
   public void testDemo() throws Exception {
      IUIContext ui = getUI();
      ui.click("file/New Contact..."));
      ui.wait(new ShellShowingCondition(""));
      ui.enterText("3");
      ui.keyClick(WT.TAB);
      ui.enterText("4");
      ui.click(new LabeledTextLocator("Street"));
      ui.click(new ButtonLocator("&Finish"));
      ui.close(new SWTWidgetLocator(Shell.class, "RCP Contacts Editor"));
      ui.wait(new ShellDisposedCondition("RCP Contacts Editor"));
         }

MyTestSuite.java
Code: Select all
public class MyTestSuite extends TestCase
{
    public static Test suite()
    {
        TestSuite suite = new TestSuite();       
        suite.addTestSuite(Demo.class);
        suite.addTestSuite(Demo2.class);
        return suite;
    }
}


will anyone give an example how to apply setup(),teardown() for this case?
vcycyv
 
Posts: 2
Joined: Mon Mar 31, 2008 10:19 pm

Re: how to use WindowTester for multiple junit cases?

Postby Phil Quitslund » Tue Apr 08, 2008 10:53 am

Some ideas are posted here:

viewtopic.php?f=5&t=1742

In cases where you're testing a dialog or wizard, it makes sense to close them at the end of the test. That said, are you sure you want to close the application after each test? Closing the application after each test is usually not what you really want...
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest