Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Non-RCP SWT-testing(Suggestions, documentation and examples of non-RCP SWT-testing using SWTBot)
icon5.gif  Non-RCP SWT-testing [message #523744] Mon, 29 March 2010 07:07 Go to next message
Göran Öberg is currently offline Göran ÖbergFriend
Messages: 1
Registered: March 2010
Location: Sweden
Junior Member
Hello,

I am setting up a function test framework with SWTBot to be run from Hudson. The application under test is an application that is not RCP (due to some specific start-up issues) but just as heavily based on Eclipse, e.g. based on SWT.

I have a couple of working smoke tests that runs ok from within Eclipse. However, as I created them using "Run As > SWTBot Test", it seems they are assuming the application is a RCP. My problem is that I can not get them to work outside of Eclipse, from the command line or from ant.

During my development of these first few tests I have found answers to several questions here in the forum, for example handling of context-menus, so I will call on the wisdom of the forum to help me with this question:

Where can I find documentation or examples of the proper procedure for testing a generic SWT-based application with SWTBot? Examples using ant or even Hudson would be extra appreciated.


Best regards

/G

[Edit: I am using Eclipse 3.4.1 and SWTBot 2.0.0.512-dev34]

[Updated on: Mon, 29 March 2010 09:16]

Report message to a moderator

Re: Non-RCP SWT-testing [message #523824 is a reply to message #523744] Mon, 29 March 2010 13:51 Go to previous messageGo to next message
Pascal G is currently offline Pascal GFriend
Messages: 157
Registered: July 2009
Senior Member
Göran Öberg wrote:
> Hello,
>
> I am setting up a function test framework with SWTBot to be run from
> Hudson. The application under test is an application that is not RCP
> (due to some specific start-up issues) but just as heavily based on
> Eclipse, e.g. based on SWT.
>
> I have a couple of working smoke tests that runs ok from within Eclipse.
> However, as I created them using "Run as SWTBot Test", it seems they are
> assuming the application is a RCP. My problem is that I can not get them
> to work outside of Eclipse, from the command line or from ant.
>
> During my development of these first few tests I have found answers to
> several questions here in the forum, for example handling of
> context-menus, so I will call on the wisdom of the forum to help me with
> this question:
>
> Where can I find documentation or examples on the proper procedure for
> testing a generic SWT-based application with SWTBot? Examples using ant
> or even Hudson would be extra appreciated.
>
>
> Best regards
>
> /G
>

That's an interesting question! I think right now SWTBot does support
your use case partially. I'll try and give you information in this
answer, since I don't remember seeing any information related to this on
SWTBot's wiki.

As of now, there is only generic helpers in SWTBot to launch RCP
applications or even Eclipse plug-ins because it relies on the OSGi
platform to find and launch the required application. In your case, this
isn't good, since you don't have an OSGi runtime. I think it's
impossible for SWTBot to provide a generic way to test SWT-only
application, without OSGi.

But, fear not, there might as well be a workaround for this! What I
think could be done is that you give another entry point to the JVM
(another main) which would launch your application in a separate thread,
THAT MUST BECOME THE UI THREAD, and then launch the SWTBot thread.
Something like this:

main(String[] args)
{
Runnable runnable = new Runnable()
{
public void run()
{
YourApplication.main(args);
}
}
Thread uiThread = new Thread(runnable);
uiThread.start();

// Run the Junit test.
}

Now then, the "Run the Junit test" part depends on which version of
Junit you are using. I'm not too versed in the How To of this, but you
can take a peek at
org.eclipse.swtbot.eclipse.junit4.headless.EclipseTestRunner #getTest(String)
for ideas. Or even someone else can give more information.

Hope this helps.
--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/

*Because performance matters.*
Re: Non-RCP SWT-testing [message #523838 is a reply to message #523744] Mon, 29 March 2010 14:49 Go to previous message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
You'll need to annotate your test class with your own implementation of
SWTBotApplicationLauncherClassRunner[1].

You'd normally subclass SWTBotApplicationLauncherClassRunner to launch
your application and the tests look as normal JUnit/SWTBot tests.

However make sure that you don't launch them as swtbot tests from the
IDE; they should be launched as good-old junit tests.

Cheers!

-- Ketan
twitter.com/ketanpkr | ketan.padegaonkar.name

[1] -
http://download.eclipse.org/technology/swtbot/galileo/dev-bu ild/apidocs/org/eclipse/swtbot/swt/finder/junit/SWTBotApplic ationLauncherClassRunner.html

On 3/29/10 12:07 AM, Göran Öberg wrote:
> Hello,
>
> I am setting up a function test framework with SWTBot to be run from
> Hudson. The application under test is an application that is not RCP
> (due to some specific start-up issues) but just as heavily based on
> Eclipse, e.g. based on SWT.
>
> I have a couple of working smoke tests that runs ok from within Eclipse.
> However, as I created them using "Run as SWTBot Test", it seems they are
> assuming the application is a RCP. My problem is that I can not get them
> to work outside of Eclipse, from the command line or from ant.
>
> During my development of these first few tests I have found answers to
> several questions here in the forum, for example handling of
> context-menus, so I will call on the wisdom of the forum to help me with
> this question:
>
> Where can I find documentation or examples on the proper procedure for
> testing a generic SWT-based application with SWTBot? Examples using ant
> or even Hudson would be extra appreciated.
>
>
> Best regards
>
> /G
>
Previous Topic:SWTBot with Eclipse
Next Topic:Tree/Table editing with SWTBot
Goto Forum:
  


Current Time: Fri Nov 21 19:31:53 GMT 2014

Powered by FUDForum. Page generated in 0.01529 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software