Jump to: navigation, search

SMILA/Documentation/HowTo/Create a test bundle (plug-in)

This page descibes how to create a new test bundle for SMILA.

The description on how to add a plug-in bundle can be found in How to create a bundle (plug-in). This how to will be much the same with only minor differences.

Create the empty project

The following steps must be performed to create the test project base:

Select the New Project wizard

Launch eclipse, invoke the New Project wizard (menu File > New > Project), and click Plug-in project.

Click Next.

Now you have to fill in various metadata and settings for your plug-in project. You can edit these later on by opening the MANIFEST.MF with the Plug-in Manifest Editor.

Define Plug-in Project settings

Set the Plug-in Project settings:

  • Enter a project name (you should use the same name as the bundle that should be tested and add a .test to it, for this example we will use org.eclipse.smila.integration.bundle.test).
  • add code to the source and output folder:
    • set Source folder to code/src
    • set Output folder to code/bin
  • set Target Platform to an OSGi framework: Equinox

Click Next.

Define Plug-in Content settings

Fill in the metadata information for the new bundle.

Set the Plug-in's name as ID, your bundle's version, a reasonable bundle name and the information about the provider (i.e. you).

For our example:

  • ID: org.eclipse.smila.integration.bundle.test (in our example)
  • Version: 1.0.0
  • Name: Example Bundle Plugin Test
  • Provider: Example company
  • Exection Environment: JavaSE-1.6

Normally you won't need an activator in the test bundle, so uncheck this option.

Click Next.

Templates

Uncheck the Option Create a plug-in using one of the templates.

Click Finish.

Create a test suite file

Now you should create a test suite in your test bundle.

  • Open your MANIFEST.MF file
  • Switch to the Dependencies page.
  • in Imported Packages click Add..
  • add junit.framework (3.8.2)
  • Save MANIFEST.MF
  • Create a package in code/src with the same name as your bundle (in our example org.eclipse.smila.integration.bundle.test).
  • Add an empty test suite named AllTests.java
    • Here you can add all your bundle's tests after you've created them.

Prepare the testing gear

Now you have to make some additions to the project in order to be able to integrate it into the build process or create plug-in test launchers.

Prepare launcher

  • Create a configuration folder in your test bundle's root folder.
  • Add this configuration folder to your build.properties
  • add a log4j.properties file in your configuration folder
  • if you need plug-ins to be started for your test (which is normally the case), create a config.ini file in your configuration folder containing your OSGi bundles config.
  • Create a JUnit Plug-in Test launcher for your AllTests.java suite.
  • open the launcher
    • Test panel:
      • set the name to the bundle's name (here: org.eclipse.smila.integration.bundle.test).
      • set the Test runner to JUnit 3
    • Arguments panel:
      • set the Program arguments to -os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}
      • set the VM arguments to -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger -Dlog4j.configuration=file:${eclipse_home}configuration/log4j.properties -Xms40m -Xmx256m
      • If you need additional configuration or test data files (files/folders you store in your configuration folder), you also add the following line to your VM arguments: -Dorg.eclipse.smila.utils.config.root=./configuration
        • (to add this line is a good idea in any case.)
    • Configuration panel:
      • if you have a config.ini, you have to reference it here:
        • check Use an existing config.ini file as a template
        • Point the location to your bundle's config.ini (example: ${workspace_loc:org.eclipse.smila.integration.bundle.test/configuration/config.ini}).

Hint: You can configure eclipse to add VM arguments each time a launcher is created:

  • Window --> Preferences --> Plug-in Development --> Target Platform --> Edit...
    • In the Arguments page you can set the VM arguments that will be added to each new launch configuration.

Prepare automated testing during build process

To enable the builder (using make.xml) to test your bundle automatically, you have to provide an ant file named test.xml. The easiest way is to copy one from an already existing test bundle (e.g. org.eclipse.smila.jobmanager.test).

  • Copy the test.xml file to your test bundle's root folder.
  • Edit the test.xml file:
    • Set the plugin-name property to your test bundle's name (in our example: org.eclipse.smila.integration.bundle.test).
    • Save the file.
  • include test.xml in the test bundle's build.properties