Home » Eclipse Projects » SWTBot » SWTBot/Ant
SWTBot/Ant [message #515529] |
Fri, 19 February 2010 09:39 |
David CHAUTARD Messages: 102 Registered: July 2009 |
Senior Member |
|
|
Hello,
I try to run my tests (JUnit + SWTBot), and to generate a junitreport (in html) using Ant.
I have my tests class :
@RunWith(SWTBotJunit4ClassRunner.class)
@SuiteClasses({MyTest1.class, MyTest2.class})
public class AllTests {
}
Nevertheless, I have some problems to execute my tests. I try to use http://wiki.eclipse.org/SWTBot/Ant tutorial, but I don't know how to use Ant, buildTest.xml, and library.xml.
I create a buildTest.xml :
<?xml version="1.0" encoding="UTF-8" ?>
<project name="testsuite" default="run" basedir=".">
<property name="eclipse-home" value="E:/RCP/SWTBot"/>
<property name="plugin-name" value="myPlugin.test"/>
<property name="test-classname" value="AllTests"/>
<property name="library-file" value="${eclipse-home}/plugins/org.eclipse.swtbot.eclipse.junit4.headless_2.0.0.187-dev/library.xml"/>
<target name="suite">
<property name="jvmOption" value=""></property>
<property name="temp-workspace" value="workspace" />
<ant target="swtbot-test" antfile="${library-file}" dir="${eclipse-home}">
<property name="data-dir" value="${temp-workspace}" />
<property name="plugin-name" value="${plugin-name}" />
<property name="os" value="win32" />
<property name="ws" value="workspace" />
<property name="arch" value="x86" />
<property name="classname" value="${test-classname}" />
<property name="vmargs" value=" -Xms128M -XX:MaxPermSize=512M -Xmx512M"/>
</ant>
</target>
<target name="cleanup" />
<target name="run" depends="suite,cleanup">
</target>
</project>
I don't understand if I have create my own library.xml file or use the org.eclipse.swtbot.eclipse.junit4.headless_***/library.xml. And I don't know how I launch the tests :
- launching build.xml with Ant
- or in command line, but how to manage build.xml with this code example of the tutorial :
<echo>SWTBot test</echo>
<java dir="${eclipse.home}" fork="true" output="${eclipse.test.home}/output.txt" logError="true" classname="org.eclipse.core.launcher.Main" failonerror="false">
<classpath>
<fileset dir="${eclipse.home}/plugins">
<include name="org.eclipse.equinox.launcher_*.jar"/>
</fileset>
</classpath>
<arg line="-application org.eclipse.swtbot.eclipse.junit4.headless.swtbottestapplication"/>
<arg line="-testApplication [my.test.application]"/>
<arg line="-testPluginName [my.test.plugin]"/>
<arg line="-testApplication [my.test.application]"/>
<arg line="-className [my.swtbot.TestSuite]"/>
<arg line="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,junit-results.xml"/>
<arg line="-consoleLog"/>
<jvmarg line="-Xms40m -Xmx348m -XX:MaxPermSize=512m"/>
</java>
I'm sorry if my questions are a little bit simples, but I am currently blocked on this point.
Thanks for your help,
David.
|
|
|
Re: SWTBot/Ant [message #515578 is a reply to message #515529] |
Fri, 19 February 2010 12:47 |
|
Hello,
To run SWTBot tests headlessly, you need:
* Your product with your plugins installed
* To install your test plugins, and SWTBot plugins and fragments and their dependency installed in product.
Then you can invoke the headless testing from command-line or Ant, as described in the wiki page http://wiki.eclipse.org/SWTBot/Ant
The library.xml file is a wrapper for invocation of tests with Ant, if you use the command-line or the ant command to start them, you won't need it.
HTH
David CHAUTARD a écrit :
> Hello,
> I try to run my tests (JUnit + SWTBot), and to generate a junitreport
> (in html) using Ant.
>
> I have my tests class :
> @RunWith(SWTBotJunit4ClassRunner.class)
> @SuiteClasses({MyTest1.class, MyTest2.class})
> public class AllTests {
> }
> Nevertheless, I have some problems to execute my tests. I try to use
> http://wiki.eclipse.org/SWTBot/Ant tutorial, but I don't know how to use
> Ant, buildTest.xml, and library.xml.
>
> I create a buildTest.xml :
> <?xml version="1.0" encoding="UTF-8" ?>
> <project name="testsuite" default="run" basedir=".">
> <property name="eclipse-home" value="E:/RCP/SWTBot"/>
> <property name="plugin-name" value="myPlugin.test"/>
> <property name="test-classname" value="AllTests"/>
> <property name="library-file"
> value=" ${eclipse-home}/plugins/org.eclipse.swtbot.eclipse.junit4.he adless_2.0.0.187-dev/library.xml "/>
>
>
> <target name="suite">
>
> <property name="jvmOption" value=""></property>
>
> <property name="temp-workspace" value="workspace" />
>
> <ant target="swtbot-test" antfile="${library-file}"
> dir="${eclipse-home}">
> <property name="data-dir" value="${temp-workspace}" />
> <property name="plugin-name" value="${plugin-name}" />
> <property name="os" value="win32" />
> <property name="ws" value="workspace" />
> <property name="arch" value="x86" />
> <property name="classname" value="${test-classname}" />
> <property name="vmargs" value=" -Xms128M -XX:MaxPermSize=512M
> -Xmx512M"/>
> </ant>
> </target>
>
> <target name="cleanup" />
>
> <target name="run" depends="suite,cleanup">
> </target>
>
> </project>
> I don't understand if I have create my own library.xml file or use the
> org.eclipse.swtbot.eclipse.junit4.headless_***/library.xml. And I don't
> know how I launch the tests : - launching build.xml with Ant - or in
> command line, but how to manage build.xml with this code example of the
> tutorial :
> <echo>SWTBot test</echo>
> <java dir="${eclipse.home}" fork="true"
> output="${eclipse.test.home}/output.txt" logError="true"
> classname="org.eclipse.core.launcher.Main" failonerror="false">
> <classpath>
> <fileset dir="${eclipse.home}/plugins">
> <include name="org.eclipse.equinox.launcher_*.jar"/>
> </fileset>
> </classpath>
> <arg line="-application
> org.eclipse.swtbot.eclipse.junit4.headless.swtbottestapplica tion "/>
> <arg line="-testApplication [my.test.application]"/>
> <arg line="-testPluginName [my.test.plugin]"/>
> <arg line="-testApplication [my.test.application]"/>
> <arg line="-className [my.swtbot.TestSuite]"/>
> <arg
> line=" formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJU nitResultFormatter,junit-results.xml "/>
>
> <arg line="-consoleLog"/>
> <jvmarg line="-Xms40m -Xmx348m -XX:MaxPermSize=512m"/>
> </java>
> I'm sorry if my questions are a little bit simples, but I am currently
> blocked on this point.
>
> Thanks for your help,
> David.
--
Mickael Istria - BonitaSoft S.A.
http://www.bonitasoft.com/products/downloads.php
|
|
| |
Re: SWTBot/Ant [message #515634 is a reply to message #515599] |
Fri, 19 February 2010 15:14 |
|
You could run an XSL Transformation to transform your XML file into an HTML report. I think that the task defined in library.xml shows you how to perform this transformation, and that some XSL are available beside of it.
Hower the "Tests:0 , Failures:0, Errors:0" tells you that no test was run. Did you forget some @Test annotation, or to start your test methods with test... ?
David CHAUTARD a écrit :
> Hello;
> thanks for your answer.
> When I launch my tests with "SWTBot test" in Eclipse, I export a xml
> file containing my results. And I would like to transform this file with
> JUnitReport in order to get an HTML report.
> That's why I use Ant to generate the first XML file, and then to get the
> report without using Eclipse), to compae the XML with my previous file.
> Because the report displays "Tests:0 , Failures:0, Errors:0" while the
> JUnit view in Eclipse displays 3 succedeed tests. I think my XML file
> has not the good structure, And I don't know how to manage this
> transformation.
>
> Do you have an idea?
>
> Thanks,
> David.
>
--
Mickael Istria - BonitaSoft S.A.
http://www.bonitasoft.com/products/downloads.php
|
|
| | | |
Re: SWTBot/Ant [message #516234 is a reply to message #515730] |
Tue, 23 February 2010 10:19 |
David CHAUTARD Messages: 102 Registered: July 2009 |
Senior Member |
|
|
Hy Ketan,
thanks for your answer.
I try to run my tests with ant in order to get a xml result which is JUnit conformant, to get finally a HTML report. But I have some problem to launch my application and to run my tests. Because I think my application has to be launch in order to run the SWTBot tests.
I find to ways to run my tests but none work :
The first way run all my tests, but they are all failed :
<project name="fr.actia.actidiag-feature" default="reports">
<target name="reports" depends="">
<mkdir dir=""/>
<path id="classpath">
<pathelement location="E:\Eclipse3.5_SWTBot\eclipse\plugins\org.junit4_4.5.0.v20090824\junit.jar" />
<pathelement location="myPluginPath\bin\" />
</path>
<junit fork="yes" printsummary="yes" haltonfailure="no">
<batchtest fork="yes" todir="myPluginPath" >
<fileset dir="myPluginPath\bin">
<include name="**/*Test.class" />
</fileset>
</batchtest>
<formatter type="xml" />
<classpath refid="classpath"/>
</junit>
<junitreport todir="">
<fileset dir="myPluginPath">
<include name="*.xml"/>
<exclude name="TESTS-TestSuites.xml"/>
</fileset>
<report format="noframes" todir="myPluginPath"/>
</junitreport>
</target>
</project>
The second way launch an Eclipse product, but not my product and I have a Exception in thread "WorkbenchTestable" java.lang.NoClassDefFoundError: junit/framework/TestListener exception, and my tests are not run :
<?xml version="1.0" encoding="UTF-8" ?>
<project name="testsuite" default="run" basedir=".">
<property name="eclipse-home" value="E:/Eclipse3.5_SWTBot/eclipse" />
<property name="plugin-name" value="MyPluginName" />
<property name="library-file" value="${eclipse-home}/plugins/org.eclipse.swtbot.eclipse.junit4.headless_2.0.0.187-dev/library.xml"/>
<property name="test-classname" value="MyPlugin.AllTests"/>
<property name="testProduct" value="myproduct"/>
<property name="testApplication" value="myapplication"/>
<target name="suite">
<property name="jvmOption" value=""></property>
<property name="temp-workspace" value="workspace" />
<delete dir="${temp-workspace}" quiet="true" />
<ant target="swtbot-test" antfile="${library-file}" dir="${eclipse-home}">
<property name="data-dir" value="${temp-workspace}" />
<property name="testProduct" value="${testApplication}" />
<property name="testApplication" value="${testApplication}" />
<property name="plugin-name" value="${plugin-name}" />
<property name="os" value="win32"/>
<property name="ws" value="win32"/>
<property name="arch" value="x86" />
<property name="classname" value="${test-classname}" />
<property name="vmargs" value=" -Xms128M -Xmx512M -XX:MaxPermSize=512M ${jvmOption}" />
</ant>
</target>
<target name="cleanup" />
<target name="run" depends="suite,cleanup">
<ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
<property name="includes" value="*.xml" />
<property name="output-file" value="${plugin-name}.xml" />
</ant>
</target>
</project>
What is the best way to continue, and how can I correct my problems?
Thanks,
David.
[Updated on: Tue, 23 February 2010 10:43] Report message to a moderator
|
|
| | | |
Re: SWTBot/Ant [message #516513 is a reply to message #516498] |
Wed, 24 February 2010 10:15 |
|
David CHAUTARD a écrit :
> Hello Mickael,
>
> I try tu use your blog entry, but I have the error :
> junit.framework.AssertionFailedError: null.
> Do you know what can be the problem?
>
> Thanks,
> David.
This is a JUnit error, which probably means that your tests are actually run, but that an assertNotNull statement fails in a TestCase. The output results for your tests should be available in the home folder of the product your are testing (this is defined in the formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJU nitResultFormatter,junit-results-swtbot.xml option).
If you get a results file, then congrats, you are done with your SWTBot/Ant integration. The only thing you have to do is to make your tests green.
--
Mickael Istria - BonitaSoft S.A.
http://www.bonitasoft.com/products/downloads.php
|
|
|
Re: SWTBot/Ant [message #516521 is a reply to message #516513] |
Wed, 24 February 2010 10:50 |
David CHAUTARD Messages: 102 Registered: July 2009 |
Senior Member |
|
|
Hy,
Quote: | which probably means that your tests are actually run
|
I don't think that the tests are run, because the application are not launch. I have also the message !MESSAGE Product myproduct could not be found., as I have :
<echo>SWTBot test</echo>
<java dir="${eclipse-home}" fork="true" output="${eclipse-home}/output.txt" logError="true" classname="org.eclipse.core.launcher.Main" failonerror="false">
<classpath>
<fileset dir="${eclipse-home}/plugins">
<include name="org.eclipse.equinox.launcher_*.jar"/>
</fileset>
</classpath>
<arg line="-application org.eclipse.swtbot.eclipse.core.swtbottestapplication"/>
<arg line="-testPluginName myplugin.test"/>
<arg line="-testApplication myapplication"/>
<arg line="-myproduct"/>
<arg line="-className myplugin.test.AllTests"/>
<arg line="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,junit-results.xml"/>
<arg line="-consoleLog"/>
<arg line="-data E:\junit-workspace" />
<jvmarg line="-Xms768m -Xmx768m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -Dsun.java2d.d3d=false"/>
</java>
I don't know why my product can't be found. Maybe I have to specify the config.ini file.
David.
[Updated on: Wed, 24 February 2010 10:51] Report message to a moderator
|
|
|
Re: SWTBot/Ant [message #516529 is a reply to message #516521] |
Wed, 24 February 2010 06:06 |
|
Is your application name really "myapplication"?
If you defined it in a plugin called for instance "fr.actia.gpctool.application", with an extension id "myapplication", then its name is "fr.actia.gpctool.application.myapplication". You can see the list of available application in your .product editor, or by typning from your product "java -jar plugins/org.eclipse.equinox.launcher_*.jar -application aFakeId -consoleLog" which will give you an error message containing the list of available applications.
David CHAUTARD a écrit :
> Hy,
> Quote:
>> which probably means that your tests are actually run
>
> I don't think that the tests are run, because the application are not
> launch. I have also the message !MESSAGE Product myproduct could not be
> found., as I have :
> <echo>SWTBot test</echo>
> <java dir="${eclipse-home}" fork="true"
> output="${eclipse-home}/output.txt" logError="true"
> classname="org.eclipse.core.launcher.Main" failonerror="false">
> <classpath>
> <fileset dir="${eclipse-home}/plugins">
> <include name="org.eclipse.equinox.launcher_*.jar"/>
> </fileset>
> </classpath>
> <arg line="-application
> org.eclipse.swtbot.eclipse.core.swtbottestapplication"/>
> <arg line="-testPluginName fr.actia.gpctool.editor.test"/>
> <arg line="-testApplication myapplication"/>
> <arg line="-myproduct"/>
> <arg line="-className fr.actia.extensions.test.AllTests"/>
> <arg
> line=" formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJU nitResultFormatter,junit-results.xml "/>
>
> <arg line="-consoleLog"/>
> <arg line="-data E:\Actia\junit-workspace" />
> <jvmarg line="-Xms768m -Xmx768m -XX:PermSize=256m
> -XX:MaxPermSize=256m -XX:+CMSPermGenSweepingEnabled
> -XX:+CMSClassUnloadingEnabled -Dsun.java2d.d3d=false"/>
> </java>
> I don't know why my product can't be found. Maybe I have to specify the
> config.ini file.
>
> David.
--
--
Mickael Istria - BonitaSoft S.A.
http://www.bonitasoft.com/products/downloads.php
|
|
| | |
Re: SWTBot/Ant [message #516589 is a reply to message #516582] |
Wed, 24 February 2010 13:46 |
|
In the blog post I pointed you, I suggest to use the new JUnit bundles in your test feature to fulfill both dependency and keep SWTBot working. See http://wiki.eclipse.org/Eclipse/Testing/JUnit4_Changes for more details, and the blog entry for application.
I hope next release of SWTBot will follow this move... ;) (I could help on this topic by the way).
David CHAUTARD a écrit :
> I have an other question. On the http://wiki.eclipse.org/SWTBot/Ant it
> said Quote:
>> org.junit4 (or org.junit, but not both)
>
> But how can I remove one of them? Because if I remove org.junit, I have
> error in my .product file and my ant files. And if I remove org.junit4 I
> have problems to use
> org.eclipse.swtbot.eclipse.junit4.headless.swtbottestapplica tion
>
> Thx,
> David.
--
Mickael Istria - BonitaSoft S.A.
http://www.bonitasoft.com/products/downloads.php
|
|
| | |
Re: SWTBot/Ant [message #660139 is a reply to message #516829] |
Thu, 17 March 2011 02:15 |
|
Hello David,
I also block in this point, what's worse, i not familiar with Ant.
Can you show me how you wrote you build.xml?
and do i just need only this file?
Thanks a lot.
|
|
|
Goto Forum:
Current Time: Thu Sep 19 15:27:51 GMT 2024
Powered by FUDForum. Page generated in 0.08258 seconds
|