Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Start SWTbotTest from Java Application
Start SWTbotTest from Java Application [message #24583] Thu, 26 February 2009 12:00 Go to next message
Luis Miguel is currently offline Luis MiguelFriend
Messages: 31
Registered: July 2009
Member
Hello,
I have an Junit Test Case class for to start with SWTBot for Eclipse
Plugins as http://swtbot.sourceforge.net/users-guide.html.
I have developed an UI to get inputs about my test (log path, ...). When I
execute SWTBot Tests (Junit Test Case class), I execute my UI (Java
Application) and when user click a OK button,I want my UI to invoke to my
Junit Test Case(SWTBot Test) with it configuration(Test Runner, Location,
JRE...-->swtbot.sourceforge.net/users-guide.html.).

Is there any snnipet about this?

Thanks and regards

Luis Miguel
Re: Start SWTbotTest from Java Application [message #24817 is a reply to message #24583] Fri, 27 February 2009 11:05 Go to previous messageGo to next message
Luis Miguel is currently offline Luis MiguelFriend
Messages: 31
Registered: July 2009
Member
I am researching this and I think the best way to run an SWTBot test from
a Java application is to get the .launch of our SWTBot test configuration
and run from Java application.

If we run a SWTBot test, we will have a file .launch in
Name_workspace\.metadata\.plugins\org.eclipse.debug.core\.la unches.
For example, if we run a SWTBot test with name FooTest, we will have
FooTest.launch.(http://swtbot.sourceforge.net/users-guide.html
-->"Executing SWTBot Tests for Eclipse Plugins").

In Java application, we could get this file and run it.

Someone knows how to get this?

Thanks.

Luis Miguel
Re: Start SWTbotTest from Java Application [message #24850 is a reply to message #24583] Sat, 28 February 2009 00:09 Go to previous messageGo to next message
Ketan Patel is currently offline Ketan PatelFriend
Messages: 68
Registered: July 2009
Member
I don't know what the UI is but it seems like you are inside eclipse with
Launch capabilities. If you then, it might be easy to create your own
Launcher by extending or using SWTBot launcher. It is really simple and
you can use SWTBot launcher as example. This way you can configure your
own app and swtbot in one place and launch it.

You can also look at
org.eclipse.debug.internal.ui.launchConfigurations.LaunchCon figurationManager
to see if you can get hold of the launch configuration you need. But
first option might be the easiest and most reliable.

Ketan
Re: Start SWTbotTest from Java Application [message #25055 is a reply to message #24850] Mon, 02 March 2009 08:45 Go to previous messageGo to next message
Luis Miguel is currently offline Luis MiguelFriend
Messages: 31
Registered: July 2009
Member
I am researching this and I think the best way to run an SWTBot test from
a Java application is to get the .launch of our SWTBot test configuration
and run from Java application. If we run a SWTBot test, we will have a
file .launch in
Name_workspace\.metadata\.plugins\org.eclipse.debug.core\.la unches.
For example, if we run a SWTBot test with name FooTest, we will have
FooTest.launch.(http://swtbot.sourceforge.net/users-guide.html
-->"Executing SWTBot Tests for Eclipse Plugins").

In Java application, we could get this file and run it.

Someone knows how to get this?

Thanks.

UI is an User Interface. It is possible that my translation is wrong. My
User Interface has inputs text and a button with OK. When we click a 'OK'
button, my User Interface gets the inputs and invoke to SWTBot Test with
these inputs.

User Interface is a Java appliation and code for invoke to SWTBot Test is
in the event button. I have a SWTBot launcher called FooTest.launch in
Name_workspace\.metadata\.plugins\org.eclipse.debug.core\.la unches.\FooTest.launch
but I do not know how Can I launch it from the event button. Have you got
any example?

Meanwhile I will look
org.eclipse.debug.internal.ui.launchConfigurations.LaunchCon figurationManager

Thanks!

Luis Miguel
Re: Start SWTbotTest from Java Application [message #25096 is a reply to message #25055] Mon, 02 March 2009 09:09 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
Again, what is it that you're trying to do ? Why do you need to use the
..launch file ?

Are you writing SWT Test cases or Eclipse plugin test cases? Are you
trying to get the .launch file to execute from within another java
application?

-- Ketan

On 2/3/09 14:15, Luis Miguel wrote:
> I am researching this and I think the best way to run an SWTBot test
> from a Java application is to get the .launch of our SWTBot test
> configuration and run from Java application. If we run a SWTBot test, we
> will have a file .launch in
> Name_workspace\.metadata\.plugins\org.eclipse.debug.core\.la unches.
> For example, if we run a SWTBot test with name FooTest, we will have
> FooTest.launch.(http://swtbot.sourceforge.net/users-guide.html
> -->"Executing SWTBot Tests for Eclipse Plugins").
>
> In Java application, we could get this file and run it.
>
> Someone knows how to get this?
>
> Thanks.
>
> UI is an User Interface. It is possible that my translation is wrong. My
> User Interface has inputs text and a button with OK. When we click a
> 'OK' button, my User Interface gets the inputs and invoke to SWTBot Test
> with these inputs.
>
> User Interface is a Java appliation and code for invoke to SWTBot Test
> is in the event button. I have a SWTBot launcher called FooTest.launch
> in
> Name_workspace\.metadata\.plugins\org.eclipse.debug.core\.la unches.\FooTest.launch
> but I do not know how Can I launch it from the event button. Have you
> got any example?
>
> Meanwhile I will look
> org.eclipse.debug.internal.ui.launchConfigurations.LaunchCon figurationManager
>
>
> Thanks!
>
> Luis Miguel
>
>
Re: Start SWTbotTest from Java Application [message #25136 is a reply to message #25096] Mon, 02 March 2009 09:28 Go to previous messageGo to next message
Luis Miguel is currently offline Luis MiguelFriend
Messages: 31
Registered: July 2009
Member
I am writing Eclipse plugin test cases (FooTest.launch). I am trying to
get the .launch file to execute from within another java application (User
Interface with inputs text and button). When I click on java application,
FooTest.launch should be executed.

Luis Miguel
Re: Start SWTbotTest from Java Application [message #25177 is a reply to message #25136] Mon, 02 March 2009 09:34 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
This is not supported by eclipse, and you're trying to invent a major
portion of what the launch configuration does already from your java
application.

If you could describe why you're doing this, I'm sure someone could
recommend a better and simpler way for doing this.

-- Ketan

On 2/3/09 14:58, Luis Miguel wrote:
> I am writing Eclipse plugin test cases (FooTest.launch). I am trying to
> get the .launch file to execute from within another java application
> (User Interface with inputs text and button). When I click on java
> application, FooTest.launch should be executed.
> Luis Miguel
>
Re: Start SWTbotTest from Java Application [message #25217 is a reply to message #25177] Mon, 02 March 2009 10:57 Go to previous messageGo to next message
Marc is currently offline MarcFriend
Messages: 32
Registered: July 2009
Member
Hi,

What I would do is:

find a command line that will eclipse and automatically launches the
SWTbot eclipse plug in test.

(I'm highly interested in this, but I have not started seraching for it)
might looks like "eclipse -autoLauchConfiguration mylaunchconfigswtbot"

Then your UI would not launch the whole thing from java, it would launch
this command line.
What about the test inputs then? Just write them in a file before throwing
the command line. You Eclipse swtbot test would know which file to read
and therefore find the input.

Hope this helps.
If you ever find the command line, please post it (or I will post it if
I've got the time to look for it) (I hope there is one, I'm not sure)

Bye
Marc
Re: Start SWTbotTest from Java Application [message #25258 is a reply to message #25217] Mon, 02 March 2009 11:15 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
Hi,

The SWTBot tests do something similar. The command line used by SWTBot
for running its own tests is available in [1]. This would however not
work with the way Luis is running the tests.

I'd agree with your point that it's cheaper, easier and more error proof
if the input is read from a file and read by the tests.

[1] -
http://dev.eclipse.org/svnroot/technology/org.eclipse.swtbot /trunk/org.eclipse.swtbot.eclipse.junit4.headless/library.xm l

-- Ketan

On 2/3/09 16:27, Marc wrote:
> Hi,
>
> What I would do is:
>
> find a command line that will eclipse and automatically launches the
> SWTbot eclipse plug in test.
>
> (I'm highly interested in this, but I have not started seraching for it)
> might looks like "eclipse -autoLauchConfiguration mylaunchconfigswtbot"
>
> Then your UI would not launch the whole thing from java, it would launch
> this command line.
> What about the test inputs then? Just write them in a file before
> throwing the command line. You Eclipse swtbot test would know which file
> to read and therefore find the input.
>
> Hope this helps.
> If you ever find the command line, please post it (or I will post it if
> I've got the time to look for it) (I hope there is one, I'm not sure)
>
> Bye
> Marc
>
Re: Start SWTbotTest from Java Application [message #25298 is a reply to message #25258] Mon, 02 March 2009 11:22 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
Luis,

On another thought, you'll need to hack into the SWTBot application
launcher[1] so that it takes in the necessary inputs, and recompile[2]
SWTBot sources with your changes.

[1] -
http://dev.eclipse.org/svnroot/technology/org.eclipse.swtbot /trunk/org.eclipse.swtbot.eclipse.core/src/org/eclipse/swtbo t/eclipse/core/UITestApplication.java
[2] -
http://dev.eclipse.org/svnroot/technology/org.eclipse.swtbot /trunk/org.eclipse.swtbot.releng/readme.txt

-- Ketan

On 2/3/09 16:45, Ketan Padegaonkar wrote:
> Hi,
>
> The SWTBot tests do something similar. The command line used by SWTBot
> for running its own tests is available in [1]. This would however not
> work with the way Luis is running the tests.
>
> I'd agree with your point that it's cheaper, easier and more error proof
> if the input is read from a file and read by the tests.
>
> [1] -
> http://dev.eclipse.org/svnroot/technology/org.eclipse.swtbot /trunk/org.eclipse.swtbot.eclipse.junit4.headless/library.xm l
>
>
> -- Ketan
>
> On 2/3/09 16:27, Marc wrote:
>> Hi,
>>
>> What I would do is:
>>
>> find a command line that will eclipse and automatically launches the
>> SWTbot eclipse plug in test.
>>
>> (I'm highly interested in this, but I have not started seraching for it)
>> might looks like "eclipse -autoLauchConfiguration mylaunchconfigswtbot"
>>
>> Then your UI would not launch the whole thing from java, it would launch
>> this command line.
>> What about the test inputs then? Just write them in a file before
>> throwing the command line. You Eclipse swtbot test would know which file
>> to read and therefore find the input.
>>
>> Hope this helps.
>> If you ever find the command line, please post it (or I will post it if
>> I've got the time to look for it) (I hope there is one, I'm not sure)
>>
>> Bye
>> Marc
>>
>
Re: Start SWTbotTest from Java Application [message #25458 is a reply to message #25258] Tue, 03 March 2009 14:11 Go to previous messageGo to next message
Marc is currently offline MarcFriend
Messages: 32
Registered: July 2009
Member
Hi,

I looked at the script and it seems interesting.
I've never worked with Ant script (sorry if following question seems
newbie ones, I just need to confirm),
first this is an Ant script, isn't it?
And you can call it with command line like ">ant myscript.xml"

It can be used to test Eclipse Plugin, not just SWT app?

If all of this is real, then we could put the ant command in a .bat file
and set its execution at some date by defining a task.

This is very interesting because it is another step into test automation.


At last, maybe Luis could execute this ant command from inside his java
code and get the test executed.


Bye
Marc


Ketan Padegaonkar wrote:

> Hi,

> The SWTBot tests do something similar. The command line used by SWTBot
> for running its own tests is available in [1]. This would however not
> work with the way Luis is running the tests.

[...]

> [1] -
>
http://dev.eclipse.org/svnroot/technology/org.eclipse.swtbot /trunk/org.eclipse.swtbot.eclipse.junit4.headless/library.xm l

> -- Ketan
Re: Start SWTbotTest from Java Application [message #25577 is a reply to message #25458] Tue, 03 March 2009 16:55 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
Unfortunately this looks extremely simple, but not as easy as you
mention it :)

You need a build in place that can generate your plugins, install it
into a working eclipse instance, and then use the ant scripts to run the
tests.

Googling for "pde test automation" and "pde build" should give you a
good headstart.

-- Ketan

On 3/3/09 19:41, Marc wrote:
> Hi,
>
> I looked at the script and it seems interesting.
> I've never worked with Ant script (sorry if following question seems
> newbie ones, I just need to confirm),
> first this is an Ant script, isn't it?
> And you can call it with command line like ">ant myscript.xml"
>
> It can be used to test Eclipse Plugin, not just SWT app?
>
> If all of this is real, then we could put the ant command in a .bat file
> and set its execution at some date by defining a task.
>
> This is very interesting because it is another step into test automation.
>
>
> At last, maybe Luis could execute this ant command from inside his java
> code and get the test executed.
>
>
> Bye
> Marc
>
>
> Ketan Padegaonkar wrote:
>
>> Hi,
>
>> The SWTBot tests do something similar. The command line used by SWTBot
>> for running its own tests is available in [1]. This would however not
>> work with the way Luis is running the tests.
>
> [...]
>
>> [1] -
> http://dev.eclipse.org/svnroot/technology/org.eclipse.swtbot /trunk/org.eclipse.swtbot.eclipse.junit4.headless/library.xm l
>
>
>> -- Ketan
>
>
Re: Start SWTbotTest from Java Application [message #25808 is a reply to message #25577] Wed, 04 March 2009 09:44 Go to previous messageGo to next message
hugulas chen is currently offline hugulas chenFriend
Messages: 10
Registered: July 2009
Junior Member
Marc,
I am already using ant script to test my rcp automatically.
First, you need to install your test plugins under eclipse plugin dir.
Then,you can run such a parallel task.It contains two threads: execute and
listen.
Execute Task will start your eclipse and execute your test case.
Listen task will collect the test result.
The listener can be downloaded from
http://www.eclipse.org/articles/Article-PDEJUnitAntAutomatio n/PDETestExampleProjects-3.3.zip.

This task can run one case each.I wrote a small tool to generate the test
case name list.

Finally, you can use junitreport task to generate the test report.

Ketan, may I contribute a paper about how to automate the swtbot test with
ant?

<target name="test">
<parallel>
<daemons>
<antcall target="listen" />
</daemons>
<sequential>
<sleep seconds="10" />
<!-- Give the listener a few seconds to startup -->
<antcall target="execute" />
</sequential>
</parallel>
</target>
<target name="execute">
<echo>${test.workspace}</echo>
<delete dir="${test.workspace}" />
<mkdir dir="${test.workspace}" />
<java classname="org.eclipse.equinox.launcher.Main" fork="true"
dir="${build.home}" output="reports/${testcase}.out.txt"
error="reports/${testcase}.err.txt" append="true">
<arg line="-application
org.eclipse.swtbot.eclipse.core.swtbottestapplication" />
<arg line="-classNames ${testcase} -testpluginname ${testplugin}" />
<arg line="-version 3 -testLoaderClass
org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname
org.eclipse.jdt.junit4.runtime" />
<arg line="-port 2625 -pdelaunch" />
<arg line="-data ${test.workspace}" />
<arg line="-debug -consolelog -clean" />
<classpath>
<fileset dir="${build.plugins}">
<include name="org.eclipse.equinox.launcher_*.jar" />
</fileset>
</classpath>
</java>
</target>
<target name="listen">
<java classname="pde.test.utils.PDETestResultsCollector">
<arg line="${testcase} 2625" />
<classpath>
<fileset dir="${build.plugins}">
<include name="**/*.jar" />
</fileset>
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
<fileset dir="${java.home}/lib">
<include name="**/*.jar" />
</fileset>
</classpath>
</java>
</target>

http://www.eclipse.org/articles/Article-PDE-Automation/autom ation.html

Do you want my ant script? I can share it with you.
Re: Start SWTbotTest from Java Application [message #26009 is a reply to message #25808] Wed, 04 March 2009 10:47 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
On 4/3/09 15:14, hugulas chen wrote:
> Marc,
> I am already using ant script to test my rcp automatically.
> First, you need to install your test plugins under eclipse plugin dir.
> Then,you can run such a parallel task.It contains two threads: execute
> and listen.
> Execute Task will start your eclipse and execute your test case.
> Listen task will collect the test result.
> The listener can be downloaded from
> http://www.eclipse.org/articles/Article-PDEJUnitAntAutomatio n/PDETestExampleProjects-3.3.zip.

> Do you want my ant script? I can share it with you.

Could you put this up on the SWTBot Wiki ?

-- Ketan
Re: Start SWTbotTest from Java Application [message #26298 is a reply to message #25808] Thu, 05 March 2009 13:50 Go to previous message
Marc is currently offline MarcFriend
Messages: 32
Registered: July 2009
Member
Hi,

Thanks for all that details, it is still a bit confusing to me as I'm
completely discovering ant and all of this.

I think I'd greatly appreciate any paper about it.
I going on holydays so I won't be working on it for 10 days. But after
I'll be working on.

Bye
Marc
Previous Topic:Moving towards a 'more formal' 2.0 release.
Next Topic:How to record and playback a SWTBot testcase
Goto Forum:
  


Current Time: Sat Nov 09 03:09:34 GMT 2024

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

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

Back to the top