Non-RCP SWT-testing [message #523744] |
Mon, 29 March 2010 07:07 |
Göran Öberg 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 |
Pascal G 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.*
|
|
|
|
Powered by
FUDForum. Page generated in 0.03426 seconds