JUnit Integration Tutorial

The Code Coverage Tool provides an additional JUnit launch configuration delegate as a means to integrate with the JUnit test framework. This allows for determining the achieved code coverage for test suites containing containing test cases for Operational QVT (QVTO) model transformations. This section explains how to measure and visualize the code coverage of a test suite. Basic knowledge about EMF, QVTO, JUnit is assumed.

Note: The example created by following the tutorial is available here.

Steps

  1. Create a QVTO transformation, e.g. from this tutorial.
  2. Create a Plug-in project.
  3. Add a JUnit test case to the project
  4. Add and implement a test case. An example code snippet is listed below:
  1. Run the JUnit test (Run As -> JUnit Test)
  2. A dialog will be presented, asking to chose between the available JUnit launch delegate. This includes the one contributed by the Code Coverage Tool, which is the Operational QVT Interpreter Coverage Launcher. Either use configuration specific settings or change the workspace global setting to prefer the Operational QVT Interpreter Coverage Launcher. The former method allows ruling out the Operational QVT Interpreter Coverage Launcher in case a JUnit test suite does not include any QVT model transformations.

Select Preferred Launcher Dialog

  1. Press OK to confirm your choice. The test case will now be executed.
  2. Upon successful execution of the test case, the Operational QVT Code Coverage View is instantiated and given focus, in order to directly present the coverage data.

QVTo Test Coverage View