Unit Testing

Pre-requisites

Before you proceed make sure you've set up your Eclipse environment as explained in Setting up the Eclipse Environment and have imported the code as explained in Importing the Code.


Unit Testing the Code in Eclipse

This is a brief guide explaining how to run all of the Archi Unit tests in Eclipse. The Unit Tests use JUnit 4, the version that ships with Eclipse 3.8.2 and later. Ensure that you have imported all of the tests into the Eclipse workspace. If you have not done this yet, open the "Git Repositories" View in Eclipse and Import them into the workspace:

Import Tests


Each Unit Test project in the "tests" folder is an Eclipse "fragment" type plug-in, each one corresponding to its host plug-in. A fragment plug-in is like a priviliged extension to its host plug-in. There is also a "com.archimatetool.testsupport" plug-in that provides some testing helper support, and a "com.archimatetool.tests" plug-in which is basically a collection of all of the Unit Test plug-ins. It is this plug-in that we can run from within Eclipse. In order to do this we need to set up a Launch Configuration


Set up a Launch Configuration

  1. From the main menu choose "Run->Debug Configurations..."

  2. In the dialog select the "JUnit Plug-in Test" node

  3. Choose "New"

  4. Rename the configuration to "All Tests"

  5. Edit the tabs on the dialog as follows...


Test

Config 1


Main

Config 2

If you do not wish to see an instance of Archi being shown when the tests run then, in the "Program to Run" section, select "Run an application" and then choose the "[No Application] - Headless Mode" option from the drop-down.


Arguments

Config 3

Mac users who are running the 32-bit version of Eclipse will need to add the -d32 switch to the VM arguments.


Plug-ins

Config 4

Important!

It's very important to select "plug-ins selected below only" from the combo box in the Plug-ins tab. This means that only the required features will show up in Archi. If you select the other plug-ins the tests will not run as intended. The best way to achieve this is:

  1. Select "plug-ins selected below only" from the "Launch with:" combo box

  2. Click the "Deselect All" button to clear all selected plug-ins

  3. Select the "com.archimatetool.tests" plug-in

  4. Press the "Add Required Plug-ins" button. This will add any required Eclipse plug-ins in the "Target Platform" section

  5. Press the "Validate Plug-ins" button to ensure there are no problems


Configuration

Config 5


Next Steps

To Run/Debug all the Unit Tests press the "Debug" button from the configuration or choose "Run, Debug last launched" from the main menu if you've already run it.

When you run the tests from within Eclipse it's best to choose "Debug" rather than "Run". This way you can set breakpoints and be warned of any run-time exceptions.