Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "SWTBot/Ant"

m
m (using templates for creating links)
Line 1: Line 1:
 +
{{SWTBot}}
 
= Executing SWTBot Tests from Ant =
 
= Executing SWTBot Tests from Ant =
  
Line 69: Line 70:
  
 
The ${library-file} is part of the '''Headless Test Framework''' and can be viewed at http://github.com/ketan/swtbot/blob/master/org.eclipse.swtbot.eclipse.junit4.headless/library.xml. This ant script performs the actual launch for the tests using the command line above.
 
The ${library-file} is part of the '''Headless Test Framework''' and can be viewed at http://github.com/ketan/swtbot/blob/master/org.eclipse.swtbot.eclipse.junit4.headless/library.xml. This ant script performs the actual launch for the tests using the command line above.
 
[[Category:SWTBot]]
 

Revision as of 03:34, 1 July 2009


SWTBot
Website
Update Sites
Community
Mailing List
Forums/Newsgroups
IRC
Contribute
Open Bugzilla tickets
Open Gerrit reviews
Browse Source
Continuous Integration


Executing SWTBot Tests from Ant

SWTBot allows for tests to be executed from ant. Here are some steps that you need to perform in order to run tests in a 'headless' way.

Pre-requisites

  • Download the Headless Testing Framework for running tests from within ant. This file is called named something like org.eclipse.swtbot.eclipse.test-2.0.0.187-dev.zip
  • You'll need the following plugins from swtbot (you don't need all the swtbot packages)
    • org.eclipse.swtbot.swt.finder
    • org.eclipse.swtbot.eclipse.finder
    • org.hamcrest
    • org.junit4(recommended) you may also use org.junit
    • org.apache.log4j

Setup

Your folder structure should look like the following:

ECLIPSE_HOME
 + plugins
  | - com.yourplugins
  | - ...
  | - ...
  | - org.eclipse.swtbot.swt.finder
  | - org.eclipse.swtbot.eclipse.finder
  | - org.hamcrest (and other dependencies)
  | - ...
  | - ...
  | - org.eclipse.swtbot.ant.optional.junit4 (or junit3, but not both) (from the Headless Testing Framework)
  | - org.eclipse.swtbot.eclipse.junit4.headless (or junit3.headless, but not both) (from the Headless Testing Framework)
 + features

Executing

Here's a command line argument that's used to execute the tests:


$ ECLIPSE_HOME=/path/to/your/application
$ TEST_CLASS=com.yourcompany.AllTessts # see http://github.com/ketan/swtbot/blob/master/org.eclipse.swtbot.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/AllTests.java for an example

$ $JAVA_HOME/bin/java \
 -Xms128M -Xmx368M -XX:MaxPermSize=256M \
 -DPLUGIN_PATH= \
 -classpath $ECLIPSE_HOME/plugins/org.eclipse.equinox.launcher_1.0.200.v20090128-1500.jar \
 org.eclipse.core.launcher.Main \
 -application org.eclipse.swtbot.eclipse.junit4.headless.swtbottestapplication \
 -data workspace \
 formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,$ECLIPSE_HOME/$TEST_CLASS.xml \
 formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter \
 -testPluginName org.eclipse.swtbot.eclipse.finder.test \
 -className $TEST_CLASS \
 -os macosx -ws carbon -arch x86 -consoleLog -debug

This will run the test specified by TEST_CLASS and generate the test output in ECLIPSE_HOME/TEST_CLASS.xml. This output can be parsed using junitreport ant task.

Pre-prepared ant tasks

The script at http://github.com/ketan/swtbot/blob/master/org.eclipse.swtbot.releng/test-sandbox/org.eclipse.swtbot.eclipse.finder.test.xml shows an example of how you can use the standard ant task available with SWTBot:

   <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="classname" value="org.eclipse.swtbot.eclipse.finder.AllTests" />
       <property name="vmargs" value=" -Xms128M -Xmx368M -XX:MaxPermSize=256M ${jvmOption}" />
   </ant>

The ${library-file} is part of the Headless Test Framework and can be viewed at http://github.com/ketan/swtbot/blob/master/org.eclipse.swtbot.eclipse.junit4.headless/library.xml. This ant script performs the actual launch for the tests using the command line above.

Back to the top