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.
Difference between revisions of "SMILA/Documentation/HowTo/How to integrate test bundle into build process"
(→2. Include test plug-in into org.eclipse.eilf.test.feature) |
m (→Include test.xml in build.properties) |
||
(13 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | + | This page describes how to integrate your [[SMILA/Documentation/HowTo/Create_a_test_bundle_(plug-in)|own test bundle (plug-in)]] into the build process (Bamboo): | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | === Define Junit version range === | ||
+ | Currently, it is necessary to import <tt>junit.framework</tt> with an explicit version range: | ||
+ | # Open the <tt>MANIFEST.MF</tt> file of your test bundle using the ''Plug-in Manifest Editor''. | ||
+ | # Switch to the ''Dependencies'' tab and add the package <tt>junit.framework</tt> to the ''Imported Packages'' section. | ||
+ | # Make sure to set the version range of this package as follows: | ||
+ | <div style="margin-left: 2.5em"> | ||
+ | {| class="wikitable" border="1" | ||
+ | |- | ||
+ | | Minimum version | ||
+ | | 3.8.0 | ||
+ | | Inclusive | ||
+ | |- | ||
+ | | Maximun version | ||
+ | | 4.0.0 | ||
+ | | Exlusive | ||
|} | |} | ||
+ | </div> | ||
+ | === Create test.xml in test bundle === | ||
− | The following | + | The following figure shows the typical folder structure of a test bundle in the ''Package Explorer''. |
− | + | [[Image:TestPackageExplorer.png]] | |
− | + | Every test plug-in you want to run needs an Ant file called <tt>test.xml</tt>. Because each test run starts up a new Eclipse instance, it is convenient to create a plug-in bundling all your tests into a single <tt>AllTests</tt> suite. Then, there is only one test run and there must only be one <tt>test.xml</tt> file maintained. | |
− | [[Image: | + | #Provide an <tt>AllTests</tt> suite that bundles all your tests. |
+ | #Download the template file for <tt>test.xml</tt> from [[Image:Test-bundle-template.zip|Test-bundle-template.zip]] (see below). | ||
+ | #Add the file to your test bundle. | ||
+ | #Adapt the value of the property <tt>plugin-name</tt> to meet your bundle name: | ||
+ | <div style="margin-left:1.5em"> | ||
+ | <source lang="xml"> | ||
+ | ... | ||
+ | <!-- sets the properties plugin-name, and library-file --> | ||
+ | <property name="plugin-name" value="<your bundle>"/> | ||
+ | <property name="library-file" value="${eclipse-home}/plugins/org.eclipse.test/library.xml"/> | ||
+ | ... | ||
+ | </source> | ||
+ | </div> | ||
− | The | + | The code snippet below shows the template of the <tt>test.xml</tt> file. The entry point is the "run" target. Its prerequisites are "init", "suite", and "cleanup". The "suite" target calls "core-test" in <tt>library.xml</tt> with the properties necessary to start up the test host and run <tt>AllTests</tt>: |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<source lang="xml"> | <source lang="xml"> | ||
Line 33: | Line 50: | ||
<!-- The property ${eclipse-home} should be passed into this script --> | <!-- The property ${eclipse-home} should be passed into this script --> | ||
<!-- Set a meaningful default value for when it is not. --> | <!-- Set a meaningful default value for when it is not. --> | ||
− | <property name="eclipse-home" value="${basedir} | + | <property name="eclipse-home" value="${basedir}/../.."/> |
<!-- sets the properties plugin-name, and library-file --> | <!-- sets the properties plugin-name, and library-file --> | ||
− | + | <property name="plugin-name" value="org.eclipse.smila.sample.bundle.test"/> | |
− | <property name="plugin-name" value="org.eclipse. | + | |
<property name="library-file" value="${eclipse-home}/plugins/org.eclipse.test/library.xml"/> | <property name="library-file" value="${eclipse-home}/plugins/org.eclipse.test/library.xml"/> | ||
Line 55: | Line 71: | ||
<delete dir="${eit-folder}" quiet="true"/> | <delete dir="${eit-folder}" quiet="true"/> | ||
<ant target="core-test" antfile="${library-file}" dir="${eclipse-home}"> | <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}"> | ||
− | |||
<property name="data-dir" value="${eit-folder}"/> | <property name="data-dir" value="${eit-folder}"/> | ||
<property name="plugin-name" value="${plugin-name}"/> | <property name="plugin-name" value="${plugin-name}"/> | ||
<property name="classname" value="${plugin-name}.AllTests"/> | <property name="classname" value="${plugin-name}.AllTests"/> | ||
− | <property name="vmargs" value="-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl. | + | |
− | + | <!-- Activates logging (if necessary activate it--> | |
+ | <property name="vmargs" value="-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog -Dorg.apache.commons.logging.simplelog.defaultlog=debug"/> | ||
</ant> | </ant> | ||
</target> | </target> | ||
Line 81: | Line 97: | ||
</source> | </source> | ||
+ | === Include test.xml in build.properties === | ||
− | + | Add the <tt>test.xml</tt> file to the <tt>build.properties</tt> of your test bundle: | |
− | + | ||
− | + | ||
+ | <source lang="text"> | ||
+ | source.. = code/src/ | ||
+ | output.. = code/bin/ | ||
+ | bin.includes = META-INF/,\ | ||
+ | .,\ | ||
+ | test.xml | ||
+ | </source> | ||
{|width="100%" style="background-color:#d8e4f1; padding-left:30px;" | {|width="100%" style="background-color:#d8e4f1; padding-left:30px;" | ||
| | | | ||
− | ''' | + | '''Additional information''': You don't have to modify the build file (make.xml) to include a bundle in the build. The make.xml file includes all bundles (core and test), which are located under the local trunk folder (e.g. SMILA/core). If you don't want to include your new bundle into the build process, the bundle has to be explicitly excluded in the make.xml file. You also don´t have to modify the build file to include your test bundle to checkstyle, pmd and emma. The tests inside your test bundle will be automatically executed. If you don´t want to run a test, the test bundle has to be explicitly excluded in the make.xml. For further information see: [[SMILA/Development_Guidelines/Introduction to make.xml|Introduction to make.xml]]. |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|} | |} | ||
− | === | + | === Include test plug-in into org.eclipse.smila.test.feature === |
− | + | # Open the file <tt>org.eclipse.smila.test.feature/feature.xml</tt>) using the ''Feature Manifest Editor''. | |
− | + | # Switch to the ''Plug-ins'' tab and add your test bundle to the ''Plug-ins and Fragments'' section. | |
− | + | # Select the added plug-in and enable the option "Unpack the plug-in archive after the installation" in the ''Plug-in Details'' section. If you don't enable this option, the bundle's <tt>test.xml</tt> file won't be found and the build process will fail. | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | For further information see: ''[[SMILA/Development_Guidelines/Build and Test Eclipse Product|Build and Test Eclipse Product]]''. |
Latest revision as of 11:23, 25 January 2012
This page describes how to integrate your own test bundle (plug-in) into the build process (Bamboo):
Contents
Define Junit version range
Currently, it is necessary to import junit.framework with an explicit version range:
- Open the MANIFEST.MF file of your test bundle using the Plug-in Manifest Editor.
- Switch to the Dependencies tab and add the package junit.framework to the Imported Packages section.
- Make sure to set the version range of this package as follows:
Minimum version | 3.8.0 | Inclusive |
Maximun version | 4.0.0 | Exlusive |
Create test.xml in test bundle
The following figure shows the typical folder structure of a test bundle in the Package Explorer.
Every test plug-in you want to run needs an Ant file called test.xml. Because each test run starts up a new Eclipse instance, it is convenient to create a plug-in bundling all your tests into a single AllTests suite. Then, there is only one test run and there must only be one test.xml file maintained.
- Provide an AllTests suite that bundles all your tests.
- Download the template file for test.xml from File:Test-bundle-template.zip (see below).
- Add the file to your test bundle.
- Adapt the value of the property plugin-name to meet your bundle name:
... <!-- sets the properties plugin-name, and library-file --> <property name="plugin-name" value="<your bundle>"/> <property name="library-file" value="${eclipse-home}/plugins/org.eclipse.test/library.xml"/> ...
The code snippet below shows the template of the test.xml file. The entry point is the "run" target. Its prerequisites are "init", "suite", and "cleanup". The "suite" target calls "core-test" in library.xml with the properties necessary to start up the test host and run AllTests:
<?xml version="1.0"?> <project name="testsuite" default="run" basedir="."> <!-- The property ${eclipse-home} should be passed into this script --> <!-- Set a meaningful default value for when it is not. --> <property name="eclipse-home" value="${basedir}/../.."/> <!-- sets the properties plugin-name, and library-file --> <property name="plugin-name" value="org.eclipse.smila.sample.bundle.test"/> <property name="library-file" value="${eclipse-home}/plugins/org.eclipse.test/library.xml"/> <!-- This target holds all initialization code that needs to be done for --> <!-- all tests that are to be run. Initialization for individual tests --> <!-- should be done within the body of the suite target. --> <target name="init"> <tstamp/> <delete> <fileset dir="${eclipse-home}" includes="${plugin-name}*.xml"/> </delete> </target> <!-- This target defines the tests that need to be run. --> <target name="suite"> <property name="eit-folder" value="${eclipse-home}/eit_folder"/> <delete dir="${eit-folder}" quiet="true"/> <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}"> <property name="data-dir" value="${eit-folder}"/> <property name="plugin-name" value="${plugin-name}"/> <property name="classname" value="${plugin-name}.AllTests"/> <!-- Activates logging (if necessary activate it--> <property name="vmargs" value="-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog -Dorg.apache.commons.logging.simplelog.defaultlog=debug"/> </ant> </target> <!-- This target holds code to cleanup the testing environment after --> <!-- after all of the tests have been run. You can use this target to --> <!-- delete temporary files that have been created. --> <target name="cleanup"> </target> <!-- This target runs the test suite. Any actions that need to happen --> <!-- after all the tests have been run should go here. --> <target name="run" depends="init,suite,cleanup"> <ant target="collect" antfile="${library-file}" dir="${eclipse-home}"> <property name="includes" value="${plugin-name}*.xml"/> <property name="output-file" value="${plugin-name}.xml"/> </ant> </target> </project>
Include test.xml in build.properties
Add the test.xml file to the build.properties of your test bundle:
source.. = code/src/ output.. = code/bin/ bin.includes = META-INF/,\ .,\ test.xml
Additional information: You don't have to modify the build file (make.xml) to include a bundle in the build. The make.xml file includes all bundles (core and test), which are located under the local trunk folder (e.g. SMILA/core). If you don't want to include your new bundle into the build process, the bundle has to be explicitly excluded in the make.xml file. You also don´t have to modify the build file to include your test bundle to checkstyle, pmd and emma. The tests inside your test bundle will be automatically executed. If you don´t want to run a test, the test bundle has to be explicitly excluded in the make.xml. For further information see: Introduction to make.xml. |
Include test plug-in into org.eclipse.smila.test.feature
- Open the file org.eclipse.smila.test.feature/feature.xml) using the Feature Manifest Editor.
- Switch to the Plug-ins tab and add your test bundle to the Plug-ins and Fragments section.
- Select the added plug-in and enable the option "Unpack the plug-in archive after the installation" in the Plug-in Details section. If you don't enable this option, the bundle's test.xml file won't be found and the build process will fail.
For further information see: Build and Test Eclipse Product.