Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Help with ANT [ Tutorial-Video ](How to automate using ANT)
Help with ANT [ Tutorial-Video ] [message #559141] Wed, 15 September 2010 14:09 Go to next message
Caio Bulgarelli is currently offline Caio Bulgarelli
Messages: 16
Registered: February 2010
Junior Member
Hi everyone,

I work at MOTOROLA (Brazil) in the MOTODEV Program (developer.motorola.com)
And I have working with SWTBot to automate a tool (The MOTODEV Studio For Android) in which it is based on Eclipse platform.

OK... So...
Now I need a help with ANT.

First, I'm trying to reproduce exactly what this video does:

http://download.eclipse.org/technology/swtbot/docs/videos/be ginners/SWTBotHeadlessTestingForNovices/


It was necessary to "fix" 2 lines inside /library.xml (lines 161 and 167)
OBS: and this tip doesn't shown on the Video-Turial.


So... When I executed the command "ant", I could not see the Eclipse open and see the "macro" interact with it.
(Like on the tutorial Video)

It was very fast! (3 second)

run:
BUILD SUCCESSFUL
Total time: 3 seconds


http://i752.photobucket.com/albums/xx163/caiob3/ANT_promptConsole_01.jpg

I'm using Eclipse Helios for it.

http://i752.photobucket.com/albums/xx163/caiob3/ANT_folder_plugins.jpg

What I forgot to do for this?
Please, could anyone help me?

--
Caio Bulgarelli
R&D - CM - MOTODEV
qbxt43@motorola.com

Re: Help with ANT [ Tutorial-Video ] [message #559345 is a reply to message #559141] Thu, 16 September 2010 08:51 Go to previous messageGo to next message
Victor  is currently offline Victor
Messages: 16
Registered: June 2010
Junior Member
Hi Everyone,
I have exactly the same problem.
I tried to follow the tutorial, but the eclipse does not show up and the ANT says BUILD SUCCESSFUL.
Can someone help us, please?

Thanks in advance.
Victor
Re: Help with ANT [ Tutorial-Video ] [message #559937 is a reply to message #559345] Mon, 20 September 2010 09:22 Go to previous messageGo to next message
Victor  is currently offline Victor
Messages: 16
Registered: June 2010
Junior Member
Hi everyone,
Finally, it worked for me. In the file library.xml file, under the headless plugin, I added the following lines:

java fork="true" dir="." timeout="${timeout}" jvm="${jvm}" logError="true" classname="org.eclipse.core.launcher.Main" output="${junit-report-output}/${classname}.txt">
<classpath>
<fileset dir="${eclipse-home}/plugins">
<include name="org.eclipse.equinox.launcher_*.jar" />
</fileset>
</classpath>
<arg line="${launcher-arg-line}" />
<arg line="-application org.eclipse.swtbot.eclipse.junit4.headless.swtbottestapplica tion "/>
<arg line="-testApplication ${test-classname}"/>
<arg line="-testPluginName ${plugin-name}"/>
<arg line="-os win32"/>
<arg line="-ws win32"/>
<arg line="-arch x86"/>
<arg line="-data C:\workspace\auto_workspace_temp"/>
<jvmarg line="${jvm-arg-line}" />
<sysproperty key="PLUGIN_PATH" value="${plugin-path}" />
</java>

And after that, the test runs correctly (the Eclipse opens and I can see the test) and the ant result is BUILD SUCCESSFUL.
I hope this reply helps a lot of people.

Thanks all.
Victor
Re: Help with ANT [ Tutorial-Video ] [message #635792 is a reply to message #559937] Thu, 28 October 2010 03:35 Go to previous messageGo to next message
toni  is currently offline toni
Messages: 8
Registered: October 2010
Junior Member
@Victor: you meant build.xml or library.xml?

Could you please post the complete file here?


Thanks a lot!
Re: Help with ANT [ Tutorial-Video ] [message #635859 is a reply to message #635792] Thu, 28 October 2010 07:49 Go to previous messageGo to next message
Victor  is currently offline Victor
Messages: 16
Registered: June 2010
Junior Member
Hi Toni,
I am talking about the library.xml file. This file can be found in: {eclipse-home}/plugins/org.eclipse.swtbot.eclipse.junit4.hea dless_version_number/library.xml

The entire file is:

<?xml version="1.0"?>
<!--


======================================================================
this has been copied from o.e.test plugin with some targets for SWTBot
======================================================================


-->

<project name="Library" default="usage" basedir="C:">

	<target name="usage">
		<echo message="Please refer to the testframework.html in org.eclipse.test for instructions on usage." />
	</target>

	<target name="init">
		<!--
			Parameters:
				(Mandatory)
				data-dir		- the directory for Eclipse to write its data
				plugin-name		- the name of the plugin to test
				classname		- the name of the test class

				(Optional - overrides defaults set in script)
				testProduct		- a string containing the product id to test.
				testApplication	- a string containing the application id to test.
				vmargs			- a string containing arguments to pass to the VM.
				extraVMargs		- allows separate setting of VM args from separate caller.
				timeout			- overrides default test timeout value (in milliseconds).
				test-output		- overrides default output file produced from test run.
				plugin-path		- path to root of plug-in
				useEclipseExe	- property setting forces test to launch via eclipse executable.
				junit-report-output - output directory for junit reports produced for specified classname.
		-->

		<tstamp>
			<format property="TIMENOW" pattern="HHmmssSSSS" />
		</tstamp>
		<!--property setting useEclipseExe launches tests using the eclipse executable-->
		<condition property="launchTarget" value="eclipse-test">
			<isset property="useEclipseExe" />
		</condition>
		<!--default launch target for launching tests-->
		<property name="launchTarget" value="java-test" />

		<!-- default product/application to launch -->
		<condition property="testproduct.if.available" value="-product ${testProduct}">
			<isset property="testProduct" />
		</condition>
		<property name="testproduct.if.available" value="" />

		<condition property="testapplication.if.available" value="-testApplication ${testApplication}">
			<isset property="testApplication" />
		</condition>

		<property name="testapplication.if.available" value="" />

		<!--default heap sizes when running performance tests-->
		<condition property="vmargs" value=" -Xms256M -Xmx256M">
			<equals arg1="${test.target}" arg2="performance" />
		</condition>
		<property name="extraVMargs" value="" />
		<property name="plugin-path" value="" />
		<property name="timeout" value="7200000" />
		<property name="test-output" value="${eclipse-home}/${classname}.xml" />
		<property name="junit-report-output" value="C:\results" />
		<mkdir dir="${junit-report-output}" />
	</target>

	<target name="swtbot-test" description="Eclipse application used to launch UI plugin tests." depends="init">
		<antcall target="${launchTarget}">
			<!--param name="application" value="org.eclipse.test.uitestapplication"/-->
			<param name="application" value="org.eclipse.swtbot.eclipse.junit4.headless.swtbottestapplication" />
		</antcall>
	</target>

	<target name="java-test">
		<!--default vm args-->
		<property name="vmargs" value="-Xms256m -Xmx512m" />

		<!-- this argument is needed for macosx -->
		<condition property="jvmOption" value="-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts">
			<os family="mac" />
		</condition>

		<property name="jvmOption" value="" />

		<!--set default jvm to use for testing-->
		<property name="jvm" value="${java.home}/bin/java" />

		<property name="launcher-arg-line" value="
			-application ${application}
			${testproduct.if.available}
			${testapplication.if.available}
			-data ${data-dir}
			formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test-output} formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter
			-testPluginName ${plugin-name}
			-className ${classname}
			-os ${os}
			-ws ${ws}
			-arch ${arch}
			-consoleLog
			-debug" />
		<property name="jvm-arg-line" value="${vmargs} ${extraVMargs} ${jvmOption}" />

		<echo>======================================</echo>
		<echo>Running swtbot junit tests in ${classname}</echo>
		<echo>Command line args are ${launcher-arg-line}</echo>
		<echo>JVM args are ${jvm-arg-line}</echo>
		<echo>JUnit Result File: ${junit-report-output}/${classname}.xml.</echo>
		<echo>Console output File: ${junit-report-output}/${classname}.txt.</echo>
		<echo>======================================</echo>

		<fail unless="application" message="variable 'application' not defined." />
		<fail unless="data-dir" message="variable 'data-dir' not defined." />
		<fail unless="test-output" message="variable 'test-output' not defined" />
		<fail unless="plugin-name" message="variable 'plugin-name' not defined" />
		<fail unless="classname" message="variable 'classname' not defined" />
		<fail unless="os" message="variable 'os' not defined. os can be one of win32, linux, macosx" />
		<fail unless="ws" message="variable 'ws' not defined. ws can be one of win32, wpf, gtk, carbon, cocoa" />
		<fail unless="arch" message="variable 'arch' not defined. arch can be one of x86, x86_64, ppc" />

		<pathconvert property="foundJunit3" setonempty="false" pathsep=" ">
			<path>
				<fileset dir="${eclipse-home}/plugins" includes="org.eclipse.swtbot.eclipse.junit3.headless*/META-INF/MANIFEST.MF" />
				<fileset dir="${eclipse-home}/plugins" includes="org.eclipse.swtbot.ant.optional.junit3*" />
			</path>
		</pathconvert>

		<fail if="foundJunit3">
			.
			Found org.eclipse.swtbot.eclipse.junit3.headless or org.eclipse.swtbot.ant.optional.junit3 in the plugins directory.
			JUnit 3.x and 4.x don't play well together.
			Please remove org.eclipse.swtbot.eclipse.junit3.headless and org.eclipse.swtbot.ant.optional.junit3 from the plugins dir.
		</fail>

		<java fork="true" dir="." timeout="${timeout}" jvm="${jvm}" logError="true" classname="org.eclipse.core.launcher.Main" output="${junit-report-output}/${classname}.txt">
			<classpath>
				<fileset dir="${eclipse-home}/plugins">
					<include name="org.eclipse.equinox.launcher_*.jar" />
				</fileset>
			</classpath>
			<arg line="${launcher-arg-line}" />
			<arg line="-application org.eclipse.swtbot.eclipse.junit4.headless.swtbottestapplication"/>
			<arg line="-testApplication ${test-classname}"/>
			<arg line="-testPluginName ${plugin-name}"/>
			<arg line="-os win32"/>
			<arg line="-ws win32"/> 
			<arg line="-arch x86"/>
			<arg line="-data C:\work_test"/>
			<jvmarg line="${jvm-arg-line}" />
			<sysproperty key="PLUGIN_PATH" value="${plugin-path}" />
		</java>

		<echo>======================================</echo>
		<echo>If you see errors above please see the file ${junit-report-output}/${classname}.txt for more information.</echo>
		<echo>Errors are generally caused by missing or incorrect dependencies.</echo>
		<echo>======================================</echo>

		<antcall target="collect-results" />
	</target>

	<target name="collect-results">
		<dirname property="output-dir" file="${test-output}" />
		<basename property="output-file-name" file="${test-output}" />
		<junitreport todir="${junit-report-output}" tofile="${classname}.result.xml">
			<fileset dir="${output-dir}">
				<include name="${output-file-name}" />
			</fileset>
		</junitreport>

		<style style="${eclipse-home}/plugins/org.eclipse.swtbot.eclipse.junit4.headless_2.0.0.595-dev-e36/JUNIT.XSL" basedir="${junit-report-output}" includes="${classname}.result.xml" destdir="${junit-report-output}" />

		<!--save .log content and *.log content from configuration directory-->
		<concat destfile="${junit-report-output}/${classname}.log">
			<fileset dir="${eclipse-home}" includes="${data-dir}/.metadata/*.log" />
			<fileset dir="${eclipse-home}" includes="configuration/*.log" />
		</concat>
	</target>

	<target name="collect">
		<!--
			This target can be used to aggragate test runs from multiple test suites into a single report.

			Parameters to this target:
			includes		- the names of the files to include
			output-file		- the name of the output file to produce
		-->
		<junitreport todir="." tofile="${output-file}">
			<fileset dir=".">
				<include name="${includes}" />
			</fileset>
		</junitreport>
	</target>

</project>


I hope it helps you.

Victor.
Re: Help with ANT [ Tutorial-Video ] [message #636091 is a reply to message #559141] Fri, 29 October 2010 05:32 Go to previous message
toni  is currently offline toni
Messages: 8
Registered: October 2010
Junior Member
Thanks a lot! I have resolved my problem! Smile
Previous Topic:Automating the launch of SWTBot tests with Ant
Next Topic:Headless test report
Goto Forum:
  


Current Time: Thu Jul 31 05:26:57 EDT 2014

Powered by FUDForum. Page generated in 0.02106 seconds