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:
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
From the main menu choose "Run->Debug Configurations..."
In the dialog select the "JUnit Plug-in Test" node
Rename the configuration to "All Tests"
Edit the tabs on the dialog as follows...
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.
Mac users who are running the 32-bit version of Eclipse will need to add the -d32 switch to the VM arguments.
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:
Select "plug-ins selected below only" from the "Launch with:" combo box
Click the "Deselect All" button to clear all selected plug-ins
Select the "com.archimatetool.tests" plug-in
Press the "Add Required Plug-ins" button. This will add any required Eclipse plug-ins in the "Target Platform" section
Press the "Validate Plug-ins" button to ensure there are no problems
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.