Running WindowTester Pro from Maven/Tycho

Running SWTBot tests as part of your maven/tycho build cycle is rather
well documented and pretty straight forward (see for example the
sonatype docs). Doing so with a WindowTester Pro recorded test is
not – but then again it is pretty straigt forward as well.

There are just two things that you need to change from the SWTBot tests
pom.xml (as presented in the sonatype docs):

  • have useUIThread = true
  • add a dependecy to com.windowtester.runtime.feature.group to pull
    in platform specific plugins

You will also need to tell maven/tycho where to find the latter feature,
of course, by adding
http://dl.google.com/eclipse/inst/windowtester/beta/3.7 to your
repositories.

A sample pom.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
  xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelversion>4.0.0</modelversion>
  <parent>
    <artifactid>de.van_porten.vrest.build</artifactid>
    <groupid>de.van_porten</groupid>
    <version>0.0.1-SNAPSHOT</version>
    <relativepath>../de.van_porten.vrest.build</relativepath>
  </parent>
  <groupid>de.van_porten</groupid>
  <artifactid>de.van_porten.vrest.tests.recorded</artifactid>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>eclipse-test-plugin</packaging>

  <repositories>
    <repository>
      <id>windowtester</id>
      <layout>p2</layout>
      <url>http://dl.google.com/eclipse/inst/windowtester/beta/3.7</url>
    </repository>
  </repositories>

  <build>
    <plugins>
      <plugin>
        <groupid>org.eclipse.tycho</groupid>
        <artifactid>tycho-surefire-plugin</artifactid>
        <version>${tycho-version}</version>

        <configuration>
          <testsuite>de.van_porten.vrest.tests.recorded</testsuite>
          <testclass>de.van_porten.vrest.tests.recorded.AllTests</testclass>

          <useuiharness>true</useuiharness>
          <useuithread>true</useuithread>
          <!-- use our product and application to launch the tests -->
          <product>de.van_porten.vrest.bundle.product</product>
          <application>org.eclipse.ui.ide.workbench</application>

          <dependencies>
            <dependency>
              <type>p2-installable-unit</type>
              <artifactid>com.windowtester.runtime.feature.group</artifactid>
              <version>0.0.0</version>
            </dependency>
          </dependencies>
        </configuration>

      </plugin>
    </plugins>
  </build>


  <profiles>
    <profile>
      <id>osx</id>
      <activation>
        <property>
          <name>java.vendor.url</name>
          <value>http://www.apple.com/</value>
        </property>
      </activation>
      <build>
        <pluginmanagement>
          <plugins>
            <plugin>
              <groupid>org.eclipse.tycho</groupid>
              <artifactid>tycho-surefire-plugin</artifactid>
              <version>${tycho-version}</version>
              <configuration>
                <argline>-XstartOnFirstThread</argline>
              </configuration>
            </plugin>
          </plugins>
        </pluginmanagement>
      </build>
    </profile>
  </profiles>

</project>

Running Tycho in Jenkins/Hudson

When I first started running my Tycho/Maven build of my visual editor in
Jenkins the build would always fail if a single test failed. That was
mainly because the Maven build would run the surefire test automatically
but cancel the build if there were any failures in them. In turn, this
would not keep artifacts from being generated and thus not create a new
snapshot release. To make matters worse, my tests are not that stable
yet – running them on Linux sometimes fails for no reason whatsoever,
leading to yet another broken build.

Now, this is obviously not what you (or Jenkins, for that matter) would
expect to happen. What I wanted and what I guess you would normally want
is for the build to pass but for Jenkins to mark the build as
"unstable".

To acomplish this on the command line, you simply need to tell Maven to
ignore test failures

mvn clean install -Dmaven.test.failure.ignore=true

With Jenkins, this is equally straight forward:

image0

Now Jenkins acts nicely and reports unstable builds while still
producing all artifacts.

vRest maven build finally working

I finally managed to get the Maven-based build of my Eclipse-based
graphical editor to work – including unit and swtbot-ui tests:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] de.van_porten.vrest.build ......................... SUCCESS [0.077s]
[INFO] de.van_porten.vrest.target-platform ............... SUCCESS [0.112s]
[INFO] de.van_porten.vrest.core .......................... SUCCESS [2.842s]
[INFO] de.van_porten.vrest.core.edit ..................... SUCCESS [0.869s]
[INFO] de.van_porten.vrest.core.editor ................... SUCCESS [0.829s]
[INFO] de.van_porten.vrest.bundle ........................ SUCCESS [0.105s]
[INFO] de.van_porten.vrest.help .......................... SUCCESS [0.076s]
[INFO] de.van_porten.vrest.ui ............................ SUCCESS [1.387s]
[INFO] de.van_porten.vrest.ui.properties ................. SUCCESS [3.650s]
[INFO] de.van_porten.vrest.feature ....................... SUCCESS [0.113s]
[INFO] de.van_porten.vrest ............................... SUCCESS [1:08.099s]
[INFO] de.van_porten.vrest.tests.core .................... SUCCESS [4.087s]
[INFO] de.van_porten.vrest.tests.ui ...................... SUCCESS [13.315s]
[INFO] de.van_porten.vrest.p2-repository ................. SUCCESS [2.498s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3:02.410s
[INFO] Finished at: Sat Nov 26 22:22:30 CET 2011
[INFO] Final Memory: 97M/231M
[INFO] ------------------------------------------------------------------------

I’ll push to Jenkins now and see if the continous build and test also
works there. Cross your fingers.

The one thing that is bugging me is an oddness with my target platform
defintion that for some reason doesn’t want to resolve
org.apache.batik.* properly – once I switch target to the development
platform everything works as expected. But I will figure that one out
eventually ..

More on the culprits and solutions I have to follow shortly.