Reviewing the results of the unit test

Even the simplest code has some part that executes conditionally, and we need to be sure we have tested all of the code. The test framework allows us to assess how much of the code was actually tested. This is called code coverage.

This time, we will turn on code coverage, which is done by the following steps:

  1. In the unit test toolbar, click on Parameters.
  2. In the form, check both Record code coverage and Record number of records.
  3. Run the test again, and click on Details once the test completes. This form shows a record for each test run and some statistics and details about the test.
  4. Select the last test run and click on Tests.
  5. Since the last test was just for one class, we will see one record in the list of test cases, and a record for each test method, as shown here:
    Reviewing the results of the unit test
  6. To check the code that was covered for the test case, click on Coverage in the top-right corner and press Compare on the Code coverage form.
  7. Expand the Methods node, select initFromConFMSVehicleTable, and review the results, as shown in the following screenshot:
    Reviewing the results of the unit test

Here, we can see that line 9 was not executed or covered by our test, hence the tick symbol that is not in a green circle. We can also see that the update method was not covered at all.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.96.105