I now use this:

import org.eclipse.swt.examples.addressbook.AddressBook;
import org.junit.Before;
import org.junit.Test;

public class BlaTest {
    
    @Before
    public void startClient()
    {
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                AddressBook.main(null);
            }
        };
        Thread guiThread = new Thread(runnable);
        guiThread.start();
    }
    
    @Test
    public void me() throws Exception
    {
        Thread.sleep(3000);
        System.out.println("XXX");
    }

}


--- On Thu, 10/9/08, Ketan Padegaonkar <[EMAIL PROTECTED]> wrote:
From: Ketan Padegaonkar <[EMAIL PROTECTED]>
Subject: Re: [SWTBot-users] [ANN] SWTBot 2.0 alpha available.
To: swtbot-users@lists.sourceforge.net
Date: Thursday, October 9, 2008, 3:27 PM

On 10-Oct-08, at 12:47 AM, Hans Schwaebli wrote:

> That does not work great, it freezes:
>
> import org.eclipse.swt.examples.addressbook.AddressBook;
> import org.junit.Test;
>
> public class BlaTest {
>     @Test
>     public void me() {
>         AddressBook.main(null);
>         // freezes after previous statement
>         // so no SWTBot statements can be run after the GUI started
>     }
> }


This is bound to freeze as you correctly pointed out.

The only way I see this work is to start the application in a method  
annotated as @Before and make that the super class of all your classes:

public class BaseTest {
   private static boolean  initialized  = false;
   @BeforeClass
   public static void startApplication() {
     if (!initialized)
       startApplication();
     initialized = true;
   }
}

You can then make BlaTest extend from BaseTest

-- Ketan


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's
challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
SWTBot-users mailing list
SWTBot-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swtbot-users
http://swtbot.org/ - a functional testing tool for SWT/Eclipse




      
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
SWTBot-users mailing list
SWTBot-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swtbot-users
http://swtbot.org/ - a functional testing tool for SWT/Eclipse

Reply via email to