Hi Somesh,

The reason why this fails is two fold:
1. Running JUnit plugin tests run in the UI thread. SWTBot should  
'ideally' be run in non-UI thread.
2. The New Java project dialog (like most others) is a blocking dialog  
and blocks tests because they run in the UI thread.

The trick here is to run the test as a SWTBot test-case. There's a  
right click option under in order to be able to do this. The launcher  
ensures that the tests run in a non-UI thread.

Also you could extend from SWTBotTestCase which is part of 1.0. You  
will get some new assertions and a bunch of cool features if you  
subclass from SWTBotTestCase. Watch out for 1.1 which should be out  
this or next weekend :)

Documentation is bad, I agree! It's a one man army and I can only do  
so much. Do feel free to add stuff to the Wiki if you feel to.

PS: You need to subscribe to the mailing list in order to post.

Cheers,
Ketan Padegaonkar
I blog... therefore I am... http://ketan.padegaonkar.name
http://swtbot.org/ - a functional testing tool for SWT/Eclipse



On 30-May-08, at 7:43 AM, Somesh Sasalatti wrote:

> Hi Ketan,
> you probably don't remember me but we had lunch on the first day at  
> EclipseCon 2008.
> Anyhow, I am trying to use SWT Bot to test a plugin that we have  
> written.
>
> I am trying to invoke a wizard and type stuff in it and press finish.
> It opens up the wizard but hangs in menu.click(); and therefore I  
> can't seem to continue.
>
> I  tried creating a test case to invoke the standard java project  
> wizard
> here is the some sample code that i tried but it didn't work
>
> added a file in a fresh plugin project
>
>
> import org.eclipse.swt.widgets.Widget;
>
> import net.sf.swtbot.SWTBot;
> import net.sf.swtbot.SWTBotTestCase;
> import net.sf.swtbot.eclipse.finder.SWTEclipseBot;
> import net.sf.swtbot.widgets.SWTBotMenu;
> import net.sf.swtbot.widgets.SWTBotShell;
> import net.sf.swtbot.widgets.TimeoutException;
> import net.sf.swtbot.widgets.WidgetNotFoundException;
>
> public class test extends TestCase{
>
>     public void testProjectInvoke() throws WidgetNotFoundException{
>         SWTEclipseBot bot = new SWTEclipseBot();
>         bot.menu("File").menu("New").menu("Java Project").click();
>         try {
>             bot.shell("New Java Project").activate();
>             bot.textWithLabel("Project name:").setText("MyProject");
>             bot.button("Finish").click();
>         } catch (TimeoutException e) {
>             // TODO Auto-generated catch block
>             e.printStackTrace();
>         }
>
>
>
>     }
>
> }
>
> ran this as a Junit-Plugin Test
>
> on running this target, a target Eclipse sdk.ide is launched, the  
> wizard shows up and hangs.
>
> I tried to debug and it seems that it doesn't come out of line 212  
> in AbstractSWTBot.java ( widget.notifyListeners(...) );
>
> Any help is appreciated.
>
> Also, I struggled to find some examples with testing Eclipse  
> Plugins. It'd be nice to have some test samples around on the wiki.  
> I do not want to go the record and play way but want to write tests  
> just like i would write a junit test.
>
> Thanks in advance.
> Somesh


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
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