Using a code coverage tool

You can use code coverage tools to find out how well the tests cover the code being tested. BullseyeCoverage is commonly used in Symbian development. The process is as follows:

  1. In BullseyeCoverage, turn on the coverage compiler by pressing the button shown in the figure below.

  2. Recompile the tests.

  3. Run the tests in the emulator.

  4. View coverage results.

Figure 15: Code coverage after test round

The results include function coverage and branch coverage. From Figure 1, it can be seen that SendSmsL() was fully tested (from a structural point of view) and ParseMsgUid() partially. In the detailed coverage view (see Figure 2), the source code is shown and branches are marked with a description if not all decision paths were executed.

Figure 16: Detailed coverage analysis

Raising the branch coverage of a method to 100 percent can be a difficult task. A common advice in unit testing is to keep test cases small and simple. This is why many test cases are needed until the target method's coverage is raised to an acceptable level. Test cases should pass the expected values for the method under test until all interesting branches in the target are walked through during execution. You may also need to modify the target object's state outside before calling the actual implementation from the test. You can achieve this by

If target class attributes are protected or private, you need to adopt a special approach, such as