Home » Eclipse Projects » SWTBot » SWTBot/Ant
SWTBot/Ant [message #515529] |
Fri, 19 February 2010 04:39  |
Eclipse User |
|
|
|
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 07:47   |
Eclipse User |
|
|
|
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 10:14   |
Eclipse User |
|
|
|
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 05:19   |
Eclipse User |
|
|
|
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 05:43] by Moderator
|
|
| | | | | | | | | | | |
Re: SWTBot/Ant [message #660139 is a reply to message #516829] |
Wed, 16 March 2011 22:15  |
Eclipse User |
|
|
|
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: Wed Jul 23 08:54:34 EDT 2025
Powered by FUDForum. Page generated in 0.52683 seconds
|