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>
  • Excellent site. Plenty of helpful info here. I am sending it to a few pals ans additionally sharing in delicious. And certainly, thanks for your sweat!

  • Karthik Kumar

    I am getting the following error . when running the windows tester pro in E4 (Eclipse 4 application). Shall i know how to fix this?

    java.lang.NoClassDefFoundError: org/eclipse/osgi/baseadaptor/loader/BaseClassLoader
    at com.windowtester.internal.runtime.bundle.BundleResolver.bundleForClass(BundleResolver.java:18)
    at com.windowtester.internal.runtime.bundle.BundleResolver.bundleNameForClass(BundleResolver.java:30)
    at com.windowtester.internal.runtime.bundle.BundleClassReference.forBundleClass(BundleClassReference.java:25)
    at com.windowtester.internal.runtime.ClassReference.forBundleClass(ClassReference.java:16)
    at com.windowtester.runtime.WidgetLocator.(WidgetLocator.java:76)
    at com.windowtester.runtime.WidgetLocator.(WidgetLocator.java:105)
    at com.windowtester.runtime.swt.locator.SWTWidgetLocator.(SWTWidgetLocator.java:159)
    at com.windowtester.runtime.swt.locator.MenuItemLocator.(MenuItemLocator.java:65)
    at com.windowtester.runtime.swt.locator.MenuItemLocator.(MenuItemLocator.java:56)
    at com.bosch.bdxeditor.abstracts.AbstractTestAction.loadBDXFiles(AbstractTestAction.java:39)
    at com.bosch.bdxeditor.action.BackwardactionTest.testBackwardAction(BackwardactionTest.java:30)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at junit.framework.TestCase.runTest(TestCase.java:176)
    at junit.framework.TestCase.runBare(TestCase.java:141)
    at com.windowtester.runtime.common.UITestCaseCommon.access$0(UITestCaseCommon.java:1)
    at com.windowtester.runtime.common.UITestCaseCommon$2.run(UITestCaseCommon.java:130)
    at com.windowtester.runtime.common.UITestCaseCommon$3.run(UITestCaseCommon.java:151)
    at com.windowtester.internal.runtime.junit.core.SequenceRunner$1.run(SequenceRunner.java:40)
    Caused by: java.lang.ClassNotFoundException: org.eclipse.osgi.baseadaptor.loader.BaseClassLoader cannot be found by com.windowtester.runtime_6.0.0.r36x201009131510
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:439)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:352)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:344)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    … 21 more