<Previous Exercise | TOC | Next Exercise>

Exercise 2: Add a test fragment with a simple JUnit test

In this exercise, we will add a simple JUnit test in a fragment to the tychodemo.bundle.
We will run the test from eclipse as a JUnit plugin test and then show how the test can be built and run by Tycho simly by adding a Maven project file pom.xml.
A failed test will also fail the headless build.

As a starting point for your convenience, the result of step 1 Create an RCP bundle has been refactored:
Common settings have been extracted to a parent POM tychodemo.parent from which all modules will inherit and which defines the reactor modules.
  1. Select File > Switch Workspace > Other... and choose folder Exercise_02_Add_Test_Fragment.
  2. Import the 2 projects from this folder into the new empty eclipse workspace using File > Import > Maven > Existing Maven Projects
  3. Right-click on tychodemo.parent, Run As > Maven install
    The build should succeed and build 2 modules:
  4. Create a new fragment project tychodemo.bundle.tests with fragment host tychodemo.bundle:
    File > New > Project > Plug-in Development > Fragment Project

    Notes:
  5. In the fragment project, create a new JUnit test case tychodemo.SimpleTest
  6. Run the test: Right-click, Run As > JUnit Plugin Test
  7. Add the fragment module to the reactor and run the build:
  8. Add the module to <modules> section of the parent pom.xml:
       		<module>../tychodemo.bundle.tests</module>
    		
  9. Right-click tychodemo.parent, Run As > Maven install
    Expected result: build should fail because of the same test failure we just saw in eclipse:
  10. Implement the test:

<Previous Exercise | TOC | Next Exercise>