Search

Component Tests

See also: Component Builds

Testing With Tycho + Maven

These instructions are a work in progress and therefore subject to change. Please report problems as a JBIDE Build/Releng JIRA.

 

  1. Tycho uses the information in the parent/pom.xml to find test cases in plugins which are identified as test plugins via their pom.xml (for example, org.jboss.tools.common.model.ui.test/pom.xml).

    In parent/pom.xml, search for maven-osgi-test-plugin and look for the list of valid test class patterns:

    <include>**/AllTests.class
    <include>**/*AllTests*.class</include>
    <include>**/*AllBotTests*.class</include>
    <include>**/*TestSuite*.class</include>

    These are the classfiles that the Tycho/Maven test runner will find and run - be sure to name your test classes to match the patterns above, and framework classes you do not want to run so they do not.

  2. In your pom.xml files, setting the following packaging type tells Tycho to run tests within this plugin:

    <packaging>eclipse-test-plugin</packaging>

    NOTE: If you have a plugin used by your tests but which does not contain test classes - just shared framework code - then place that test-related plugin in plugins/, not tests/, and set its packaging type thus:

    <packaging>eclipse-plugin</packaging>
  3. In your test plugins' MANIFEST.MF files, be sure to add the dependencies for junit3, junit4, or swtbot, as appropriate. This will ensure Tycho knows what type of test to run.

  4. Ensure that your test plugins are contained within a test feature, and that those features are aggregated into the features/pom.xml file.

  5. To run your tests, you can simply build your component and its included tests will be run, provided they are aggregated into the overall build reactor. Because Maven builds using relative path aggregation, you can simply run:

    cd ~/trunk/common/tests; mvn clean install

    You will therefore build and run all the test plugins that are contained in that folder's pom.xml.

  6. Alternatively, you can build a component's plugins, features, tests, and update site all in one step by building from that component's root folder's pom.xml:
    cd ~/trunk/common; mvn clean install
  7. To disable running tests (in this case, when rebuilding only a single plugin):
    cd ~/trunk/common/tests/org.jboss.tools.common.model.ui.test; mvn clean install -Dmaven.test.skip=true

Excluding Classes

If you have classes in your test plugins which look like tests, but are in fact abstract or framework classes and should not be run as tests, you have two options to exclude them:

1. Rename them so they don't match the default pattern of included tests in the parent pom.xml:

<includes>
         <include>**/AllTests.class</include>
         <include>**/*AllTests*.class</include>
         <include>**/*AllBotTests*.class</include>
         <include>**/*TestSuite*.class</include>
</includes>

2. Or, add special includes/excludes to your test plugin's pom.xml (or its container pom):

<build>
  <plugins>
    <plugin>
      <groupId>org.sonatype.tycho</groupId>
      <artifactId>maven-osgi-test-plugin</artifactId>
      <version>${tychoVersion}</version>
      <configuration>
        <excludes>
          <exclude>**/SmartAllTestsSuite*</exclude>
          <exclude>**/*SmartTestSuite*</exclude>
          <exclude>**/*SmartPdeTestSuite*</exclude>
        </excludes>
      </configuration>
    </plugin>
  </plugins>
</build>

Remote Debugging

To be able to debug / step through your tests, you can attach a debugger to the running Tycho/Maven build. Here's how.

  1. Run the test plugin build:
    cd ~/trunk/jmx/tests/org.jboss.tools.jmx.core.test; mvn clean install -DdebugPort=8000
  2. Wait until console output stops with this message:
    Listening for transport dt_socket at address: 8000
  3. Create Remote Java Application Configuration in Eclipse for the org.jboss.tools.jmx.core project, and point it at localhost:8000
  4.  

Testing With PDE "uberbuilder" :: Deprecated

When running tests via the PDE "uberbuilder", you must explicitly define which suites and classes to run, as well as the type of test (console, ui, swtbot) to run.

See the README.txt more information.