-
Notifications
You must be signed in to change notification settings - Fork 13
Plugin tests
Andreas Huber edited this page Mar 2, 2020
·
1 revision
- A fragment to/of a plugin can access the same dependencies as the host plugin and is loaded with the same class loader
- File -> New -> Other -> Plug-in Development -> Fragment Project
- Set Project name to
nameOfYourPluginUnderTest.tests
- E.g.
de.tudresden.slr.metainformation -> de.tudresden.slr.metainformation.tests
- E.g.
- Deselect use default location
- Set Location to
pathToYourSlrRepo/tests/nameOfYourNewTestProject
- Click Next
- Set Version to the version you are working on, e.g.
0.3.0.qualifier
- In the section Host Plug-in, set Plug-in ID to the plugin under test. When done via the Browse button, the correct versions will be specified automatically
- Click Finish
- Open
yourNewFragmentProject/META-INF/MANIFEST.MF
in Eclipse with the Plug-in Manifest Editor (should be done automatically, if not, right click and click Open with) - Go to tab Dependencies, click Add in the Required Plug-ins section
- search and add de.tudresden.slr.tests.parent, save the changes
- Right click on the new test project, then Configure -> Convert to Maven Project
- In Packaging, enter eclipse-test-plugin (pom.xml will then display errors, don't worry)
- Remove version tags, version will be implicitly specified by parent pom
- Add a parent pom with the following declarations, change the version tag of this declaration to match the parent's version
<parent>
<groupId>de.tudresden</groupId>
<artifactId>de.tudresden.slr.parent</artifactId>
<version>{version in pom.xml of parent project}</version>
<relativePath>../../plugins/de.tudresden.slr.parent/pom.xml
</relativePath>
</parent>
- Remove the group id in the new pom
- Navigate to the parent project (
de.tudresden.slr.parent
), open pom.xml in Maven POM Editor in Eclipse - In the tab Overview, section Modules, click the Add Button and add your new fragment project
- Edit pom.xml manually
- module build order is partly dependent on the order of this modules
- plugin-tests should be executed before ui tests, because ui tests take very long in comparison to plugin tests
- <
module>../../tests/de.tudresden.slr.uitests</module>
should be the last entry in the modules section
- Navigate to the plugin under test, select a class under test, right click, select New -> JUnit Test Case
- The name of the test class has to end with
Test
, otherwise the test won't be executed by the tycho surefire plugin with the standard configuration when building with maven - Select New Junit 4 test
- Don't change the package name
- Change the source folder
to yourNewFragmentProject/src
via the Browse button
- Tests can be executed via right click -> Run as JUnit Test. If internals of the eclipse platform are interwoven in the code, it can be executed as a plugin via Right click -> Run as JUnit Plug-in test
Basically it's the same workflow, but the project itself has to be a plugin project, not a fragment. Therefore, all plugins under test need to be set as required via MANIFEST.mf