Measure the coverage of a test suite

Measure the coverage of a test suite

It is important to ensure that a test suite has a high level of coverage of the rules in that rulebase. The Test Script Coverage report is used to measure the amount of coverage that an existing test suite provides by charting all of the logical paths through the rulebase and ensuring that they are all taken at some point. With this information you can then improve the quality of your test cases.

What do you want to do?

Generate a Test Script Coverage report

View the coverage for a rule

Change the coverage threshold

Change the goals used in the analysis

Save the coverage report as an XML file

Understand how coverage is measured

Analyze an existing coverage file

Change the platform used by the analyzer

Analyze test script coverage using the command line tools

Generate a Test Script Coverage report

To generate a Test Script Coverage report, go to Reports | Test Script Coverage. The test scripts in the project will be analyzed and the report will be displayed in the right hand pane.

The percentage attached at each level of the report shows the percentage of conditions at that level which have relevant values. See Understand how coverage is measured for more information on this.

View the report organized by document

By default, the report is organized by document. Colored icons give a visual indication of the coverage of each rule:

View the report organized by goal

Alternatively, you can view the report organized by goal. To do this, select Organize By Goal in the drop down box at the top of the report.

 

 

The report is broken down by each goal mentioned in any test case. Selecting any attribute in the report will show the rule that proves that attribute. Colored icons give a visual indication of the coverage of each rule:

View the coverage for a rule

When you click on a rule in the report, the bottom pane shows the rule and how the coverage has been determined:

Next to each condition in the rule is 'true' and 'false' - these values are shown in bold when that value is covered by the test suite (and are not bolded when that value is not covered).

For rules without any conditions, if the conclusion is relevant to anything, the rule is considered 100% covered and is marked as 'used' in the rule coverage browser:

Change the coverage threshold

Adequate coverage is initially defined to be 80%, but this can be changed by altering the percentage in the Coverage Threshold field at the top of the report (and then pressing Enter or clicking the Regenerate button).

Change the goals used in the analysis

By default, the analysis is based on all of the goals (outcomes) defined in the test script. You can remove goals used in the analysis by clicking on the Analysis based on X goals link at the top of the report. In the Coverage Goals dialog, unselect any goals that you do not want included in the analysis and then click OK. You will notice that all of the rules used by the goals that are no longer included in the analysis now have zero coverage.

Save the coverage report as an XML file

To save the coverage report as an XML file (so that it can be opened outside Oracle Policy Modeling), click on the Save button at the top of the report.

Understand how coverage is measured

Coverage is measured by:

  1. Taking every condition that appears in a rule (for example "the person's income < $100,000" is a condition), and
  2. Running all test cases, and
  3. Testing the relevancy of every condition in the rulebase with respect to all nominated outcomes of each test case:
    1. If a condition was never relevant to any nominated outcome then it is not covered at all.
    2. If a condition was relevant on at least one occasion, but only ever with a true value then it has partial coverage.
    3. If a condition was relevant on at least one occasion, but only ever with a false value then it has partial coverage.
    4. If a condition is relevant with both true and false values in at least one occasion, then the condition has full coverage.

NOTE: Relevancy means that it would have appeared in a decision report. For more information, see Definition of 'relevant' in decision reports.

It is important to note that attributes are not the basis for this report, and are in fact not even recognized by the test script analyzer. The analyzer only cares that at some point a condition was true and on another occasion it was false.

Analyze an existing coverage file

Every time you analyze coverage of a project's test cases, Oracle Policy Modeling automatically produces a *.coverage file for the master project (and any modules it uses) which you can reopen later. Coverage files that have been generated using the batch processor can also be opened and analyzed in Oracle Policy Modeling.

To analyze an existing coverage file:

  1. Go to Reports | Analyze Coverage File...
  2. Choose a .coverage file to analyze, then click Open.

The coverage report will be displayed in the right hand pane.

Coverage of projects that include modules

The coverage data includes the data about the rulebase plus any modules it uses, all in the same file. This means you can analyze that same file in the main project, or you can open up one of the modules that was used and analyze it there. You will still only see the rules that belong to that project, but effectively this lets you see which rules in your module are being used in the master rulebase. Since the module doesn't recognize any of the attributes from the master rulebase, the goals will be displayed with only their name, not their text, but the analysis is basically the same.

Change the platform used by the analyzer

There is both a .NET and Java coverage analyzer, so it will work if you have .NET or Java custom functions. To change the platform used by the analyzer (the default is .NET), see Change the platform that the regression tester runs on.

Analyze test script coverage using the command line tools

To build a rulebase and analyze its test script coverage using the command line tools, follow these steps:

  1. Use the command line build tool to build the project.
  2. Use the command line regression tester tool to run tests and produce a *.coverage file.
  3. Use the command line build tool a second time to transform the *.coverage file into a *.xml coverage report.

 

See also: