Target Executable from the Command Line [message #42907] |
Fri, 10 July 2009 13:04  |
Eclipse User |
|
|
|
I have been using SWTBot successfully for the past few weeks and am now
trying to get my tests running from the command line. I am trying to get
my tests to run on an executable file but adding the path of this file to
the -application flag doesn't work. How can I an executable file from the
command line.
Thanks,
-Mike
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Target Executable from the Command Line [message #44396 is a reply to message #42907] |
Mon, 20 July 2009 20:41   |
Eclipse User |
|
|
|
Hi Michael,
I have worked on a similar task and am able to launch my test cases from
cmd line using ant against my eclipse rcp application. I tried using the
wiki, but I was not able to get it to work with the packages available, so
I found an older post by Hans,
http://swtbot.org/bugzilla/show_bug.cgi?id=76 , that I used as a base to
get my test cases to run. I don't know how Keaton feels about this
approach, all I am saying is that it works correctly. Here is the step by
step:
Machine preperation
1. Download apache-ant-1.7.0/ and pde.test.utils.jar from the internet
2. Put the apache-ant-1.7.0/ on your root drive
3. Update your PATH enviornment variable to have an entry that points
to apache-ant-1.7.0/bin
4. Download Eclipse RCP (for plugin developers) from eclipse.org and
unzip it to your root directory
5. put the pde.test.utils.jar file into the eclipse/plugins directory
of the ECLIPSE INSTANCE YOU DOWNLOADED IN STEP 4
6. Go to the eclipse/plugins directory of the ECLIPSE APPLICATION THAT
YOU WISH TO TEST (different then eclipse instance in step 5). In the
plugins dir, create a new dir called reports/
7. In the reports dir, create 2 files, one called demotest.txt and the
other called demotest.err.txt
8. Copy the build.xml file (posted at the end of this response, update
the fields to reflect your product.
9. Make sure your Java_Home env variable points to your JDK
Incase you wonder why you have the additional eclipse for pde.utils.jar,
it's becuase of what Keaton said about getting the results using an open
socket.. technically, a different eclipse is not requiered, but this was
the easiest way for me to do it.
Application under test setup
1) If your AUT is a simple eclipse instance that could be unzipped and
launched (such as what you download from eclipse.org, or developer builds
of the application)
* Go to your workspace where your test plugins are. Make sure they run
using the GUI.
* Select all the plugins that your test cases require
* Right click and select export.
* Copy the exported plugins to the <AUT Directory>/eclipse/plugins
directory
Running your tests from CMD line
* Bring up the command window
* Go the the AUT/eclipse/plugins directory (where the build.xml file
is located)
* Type "ant test"
Results
* An xml file will be generated in the AUT/eclipse/plugins dir that
will say which tests ran with what results.
* In AUT/eclipse/plugins/reports/ there will be two files,
demotest.txt and demotest.err. There will be some useful logging
information in these files as well
* In demotest.txt toward the bottom there will be a line that has a
summary of how many tests passed and failed.
Here is my build.xml file. Some of the initial properties are not used at
all, but I still tend to udpate them.. Here are some comments on things
you need to edit:
-classNames is your test class name.. I point it to my test suite.
-testpluginname is the plugin name that has the class in classNames
-product is the product that I want to launch
-data is the execution workspace
make sure to update the <fileset dir> in the first target to point to your
AUT's plugins dir (where the equinox.launcher is)
in the listen target, the first <arg line=> should point to your test
plugin (on port 2625)
In the listen target, the first and third <fileset dir> commands need to
point to the eclipse rcp that has your pde.util.jar plugin.
(NOTE: IF YOU DO NOT KNOW WHAT SOME OF THE PARAMETERS ARE FOR THE
BUILD.XML, HERE IS A GOOD TIP... run your test cases from the eclipse UI,
and put a break point in the first line of your test case. In the debug
perspective and debug view (the one in the top left) right click on the
thread the swtbot thread and select properties, and it will give you the
command that was used to run your tests... in this command, you can find
all the properties you want)
Hope this helps, post replies here and I'll continue to check if you need
more help.
Thanks,
Jack
build.xml
<project name="thirdparty-test" basedir=".">
<!-- ignore these variables -->
<property name="test.workspace"
location="C:\ODA\workspaces\junit-workspace"/>
<property name="testcase" location="BackupConnectedTest"/>
<property name="testplugin"
location="com.ibm.datatools.adm.db2.luw.swbtest.ui"/>
<property name="build.home" location="C:\Program Files\IBM\ODS2.2"/>
<property name="build.plugins" location="${build.home}/plugins"/>
<property name="java.home" location="C:\Program
Files\IBM\ODS2.2\jdk"/>
<property name="ant.home" location="C:\apache-ant-1.7.1\bin"/>
<!-- end ignore these variables -->
<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>Debut target execute</echo>
<!--echo>${test.workspace}</echo-->
<!--delete dir="${test.workspace}" />
<mkdir dir="${test.workspace}" /-->
<!-- -classpath
/plugins/org.eclipse.equinox.launcher_1.0.101.R34x_v20080819 .jar
org.eclipse.core.launcher.Main equinox" dir="${build.home}"-->
<java classname="org.eclipse.core.launcher.Main" fork="true"
output="reports/demotest.txt" error="reports/demotest.err.txt">
<!--append="true"-->
<!--arg line="-Xms128M -Xmx368M -XX:MaxPermSize=256M" /-->
<arg line="-os win32" />
<arg line="-ws win32" />
<arg line="-arch x86" />
<arg line="-nl en_US" />
<arg line="-application" />
<arg line="org.eclipse.swtbot.eclipse.core.swtbottestapplication " />
<arg line="-classNames" />
<arg
line=" com.ibm.datatools.adm.db2.luw.swbtest.ui.ConnectedTaskAssist antGenericTestSuite "
/>
<arg line="-testpluginname" />
<arg line="com.ibm.datatools.adm.db2.luw.swbtest.ui" />
<arg line="-version" />
<arg line="3" />
<arg line="-testLoaderClass" />
<arg line="org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader " />
<arg line="-loaderpluginname" />
<arg line="org.eclipse.jdt.junit4.runtime" />
<arg line="-product" />
<arg line="com.ibm.datastudio.administrator.product.ide" />
<arg line="-port" />
<arg line="2625" />
<arg line="-pdelaunch" />
<arg line="-data" />
<arg line="C:\ODA\workspaces\junit-workspace" />
<arg line="-debug" />
<arg line="-consolelog" />
<classpath>
<fileset dir="C:\Program Files\IBM\ODS2.2\plugins">
<include name="org.eclipse.equinox.launcher_*.jar" />
</fileset>
</classpath>
</java>
</target>
<!---->
<target name="listen">
<echo>Debut target listen</echo>
<java classname="pde.test.utils.PDETestResultsCollector">
<arg line="com.ibm.datatools.adm.db2.luw.swbtest.ui 2625" />
<classpath>
<fileset dir="C:\ODA\eclipse-rcp\plugins">
<include name="*.jar" />
</fileset>
<fileset dir="${java.home}/lib">
<include name="**/*.jar" />
</fileset>
<fileset dir="${java.home}/lib">
<include name="*.jar" />
</fileset>
<fileset dir="C:\ODA\eclipse-rcp\plugins">
<include name="**/*.jar" />
</fileset>
</classpath>
</java>
</target>
</project>
|
|
|
Re: Target Executable from the Command Line [message #45041 is a reply to message #44396] |
Wed, 22 July 2009 19:55  |
Eclipse User |
|
|
|
Thanks for the help. I went through what you have written and have made
the necessary changes to your script to allow it to work with my product.
When I run it however I get a product not found error. I am attaching my
script as well as the beginning of the error log. Any ideas?
<?xml version="1.0" encoding="UTF-8" ?>
<project name="thirdparty-test" basedir=".">
<echo>Vars</echo>
<!-- ignore these variables -->
<property name="test.workspace"
location="C:\Clister\trunk/../junit-workspace"/>
<property name="testcase" location="FooBarTest"/>
<property name="testplugin" location="test.eclipse.swt"/>
<property name="build.home" location="C:\eclipse"/>
<property name="build.plugins" location="${build.home}/plugins"/>
<property name="java.home" location="C:\Program Files\Java\jre6"/>
<property name="ant.home" location="C:\ant-1.7.1\bin"/>
<!-- end ignore these variables -->
<target name="test">
<parallel>
<daemons>
<antcall target="listen" />
</daemons>
<sequential>
<!-- Give the listener a few seconds to startup -->
<sleep seconds="10" />
<antcall target="execute" />
</sequential>
</parallel>
</target>
<target name="execute">
<echo>Debug target execute</echo>
<!--echo>${test.workspace}</echo-->
<!--delete dir="${test.workspace}" />
<mkdir dir="${test.workspace}" /-->
<!-- -classpath
/plugins/org.eclipse.equinox.launcher_1.0.101.R34x_v20080819 .jar
org.eclipse.core.launcher.Main equinox" dir="${build.home}"-->
<java classname="org.eclipse.core.launcher.Main" fork="true"
output="reports/demotest.txt" error="reports/demotest.err.txt">
<!--append="true"-->
<!--arg line="-Xms128M -Xmx368M -XX:MaxPermSize=256M" /-->
<arg line="-os win32" />
<arg line="-ws win32" />
<arg line="-arch x86" />
<arg line="-nl en_US" />
<arg line="-classNames" />
<arg line="test.eclipse.swt.simple.FooBarTest" />
<arg line="-testpluginname" />
<arg line="test.eclipse.swt" />
<arg line="-application" />
<arg line="org.eclipse.swtbot.eclipse.core.swtbottestapplication " />
<arg line="-version" />
<arg line="3" />
<arg line="-testLoaderClass" />
<arg line="org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader " />
<arg line="-loaderpluginname" />
<arg line="org.eclipse.jdt.junit4.runtime" />
<arg line="-product" />
<arg line="com.fnfr.svt.editions.team.iTest_team" />
<arg line="-port" />
<arg line="2625" />
<arg line="-pdelaunch" />
<arg line="-data" />
<arg line="C:\Clister\trunk/../junit-workspace" />
<arg line="-debug" />
<arg line="-consolelog" />
<classpath>
<fileset dir="C:\eclipse\plugins">
<include name="org.eclipse.equinox.launcher_*.jar" />
</fileset>
</classpath>
</java>
</target>
<!---->
<target name="listen">
<echo>Debut target listen</echo>
<java classname="pde.test.utils.PDETestResultsCollector">
<arg line="test.eclipse.swt.simple.FooBarTest 2625" />
<classpath>
<fileset dir="C:\commandplugins\plugins">
<include name="*.jar" />
</fileset>
<fileset dir="${java.home}\lib">
<include name="**/*.jar" />
</fileset>
<fileset dir="${java.home}\lib">
<include name="*.jar" />
</fileset>
<fileset dir="C:\commandplugins\plugins">
<include name="**/*.jar" />
</fileset>
</classpath>
</java>
</target>
</project>
Install location:
file:/c:/eclipse/
Configuration file:
file:/c:/eclipse/configuration/config.ini loaded
Configuration location:
file:/c:/eclipse/configuration/
Framework located:
file:/c:/eclipse/plugins/org.eclipse.osgi_3.4.2.R34x_v200808 26-1230.jar
Framework classpath:
file:/c:/eclipse/plugins/org.eclipse.osgi_3.4.2.R34x_v200808 26-1230.jar
Debug options:
file:/C:/.options not found
Time to load bundles: 15
Starting application: 1016
!SESSION 2009-07-22 16:49:57.437
-----------------------------------------------
eclipse.buildId=M20080911-1700
java.version=1.6.0_13
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments: -classNames test.eclipse.swt.simple.FooBarTest
-testpluginname test.eclipse.swt -application
org.eclipse.swtbot.eclipse.core.swtbottestapplication -version 3
-testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader
-loaderpluginname org.eclipse.jdt.junit4.runtime -product
com.fnfr.svt.editions.team.iTest_team -port 2625 -pdelaunch
Command-line arguments: -os win32 -ws win32 -arch x86 -classNames
test.eclipse.swt.simple.FooBarTest -testpluginname test.eclipse.swt
-application org.eclipse.swtbot.eclipse.core.swtbottestapplication
-version 3 -testLoaderClass
org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname
org.eclipse.jdt.junit4.runtime -product
com.fnfr.svt.editions.team.iTest_team -port 2625 -pdelaunch -data
C:\Clister\trunk/../junit-workspace -debug -consolelog
!ENTRY org.eclipse.equinox.app 0 0 2009-07-22 16:49:58.656
!MESSAGE Product com.fnfr.svt.editions.team.iTest_team could not be found.
Application Started: 5563
!ENTRY org.eclipse.osgi 4 0 2009-07-22 16:50:04.375
!MESSAGE An error occurred while automatically activating bundle
com.fnfr.svt.configuration (275).
!STACK 0
org.osgi.framework.BundleException: Exception in
com.fnfr.svt.configuration.ConfigurationPlugin.start() of bundle
com.fnfr.svt.configuration.
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tartActivator(BundleContextImpl.java:1028)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tart(BundleContextImpl.java:984)
at
org.eclipse.osgi.framework.internal.core.BundleHost.startWor ker(BundleHost.java:346)
at
org.eclipse.osgi.framework.internal.core.AbstractBundle.star t(AbstractBundle.java:265)
at
org.eclipse.osgi.framework.util.SecureAction.start(SecureAct ion.java:400)
at
org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter .postFindLocalClass(EclipseLazyStarter.java:111)
at
org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLoc alClass(ClasspathManager.java:427)
at
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.fin dLocalClass(DefaultClassLoader.java:193)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findLo calClass(BundleLoader.java:368)
Thanks for your help,
- Mike
|
|
|
Powered by
FUDForum. Page generated in 0.10272 seconds