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.
Papyrus/Papyrus Developer Guide/Add JUnit Test Bundle
This page outlines the steps involved in adding a new JUnit test bundle.
Basic Bundle Layout
All Papyrus test bundles are standard Eclipse plug-in projects. In particular, they
- are packaged as Eclipse plug-in bundles, not fragment bundles. Historically, some Papyrus tests have been packaged as fragments of the plug-in under test for the convenience of merging package namespaces and access to protected or package-private APIs. In practice, this caused classpath problems such as dependency cycles and failures of various PDE tools, plus mysterious resolution problems in the Tycho build. There are plenty of ways to achieve test coverage without resorting to fragment bundles
- are stored in the git repository in either the /tests/junit/plugins/ or /tests/junit/extraplugins/ tree, according to whether the bundle under test is a main release plug-in or an "extra"
- include a class named AllTests that aggregates all of the test cases into an executable unit. It should be annotated as @Headless if appropriate (see below)
- include a launch configuration with a unique name (best to just use the test project name) that launches the tests, in "headless mode" if appropriate
The org.eclipse.papyrus.core.tests bundle provides a good example.
The Hudson test build job runs all of the tests via the master org.eclipse.papyrus.tests.AllTests suite. To include your tests in this suite, ensure that
- your test bundle is referenced in some test feature that is ultimately included in the top-level org.eclipse.papyrus.tests.feature
- your test bundle is included as a child module (perhaps transitively) in the /releng/main-tests/pom.xml
- the org.eclipse.papyrus.tests.AllTests static initializer adds your test bundle's AllTests suite as a PluginTestSuiteClass sub-suite in the suiteClasses list
- the AllTestsRunner supports nesting of master suites for individual Papyrus "components" or "layers", so your test bundle may be integrated at some level of nesting. See the integration of the org.eclipse.papyrus.tests.diagramassistants.AllTests into the org.eclipse.papyrus.tests.AllTests for an example of this
If your tests can run in "headless mode", that is without the Eclipse Workbench UI being instantiated, they should be run headless. In that case, annotate your AllTests suite class with the org.eclipse.papyrus.unit.framework.runner.Headless annotation. This will cause it to be included automatically in the org.eclipse.papyrus.tests.AllHeadlessTests suite, which is simply a subset of the org.eclipse.papyrus.tests.AllTests super-suite that selects suites annotated with @Headless.