Automatic Generation of Test Cases in JSON Format Using Validator - Gnorion/BizVR GitHub Wiki

Automatic Generation of Test Cases in JSON Format Using Validator

In addition to checking the integrity of a decision model, Validator is also capable of generating test cases suitable for testing the model.

How is this done?

  1. VV first determines all the values of the input variables that are tested in the rules
  2. Then it generates every combination of these values
  3. Finally it outputs the results formatted as JSON which is suitable to be input to the decision during execution.

Here is a simple example that uses string condition values (RGB01)

image

VV will generate 2 colors x 2 sizes x 2 shapes = 8 test cases

image

Note that the rules as modeled in the table do not (yet) cover every possible combination so some test cases will get no result.

In fact VV will identify the missing cases

if color='red' and size='small' and shape='square' then result not specified
if color='green' and size='large' and shape='square' then result not specified
if color='green' and size='large' and shape='round' then result not specified
if color='green' and size='small' and shape='round' then result not specified

Here's a more complex example that uses numeric condition values and ranges: Suppose you have this decision table (VCT03B) image

Although the conditions in the table look complicated, VV is able to greatly simplify them to the following:

"R1: if age in [0..30] and income in [0..1000] then group is 'A'    ",
"R2: if age in (40..50) or  in [60..80) and income in [5000..6000] then group is 'B'    ",
"R3: if age > 100 or  in [25..50] and income in [7000..8000] then group is 'C'    ",
"R4: if age in [80..90] or  in (-4..-2) and income > 10000 then group is 'D'    "

How many test cases are required and what are they?

VV will determine that 28 test cases are required (4 incomes x 7 ages =28).

Here are the first and last few

image

image

Again, note that these rules are not yet complete. There are many gaps between the ranges such as these for age:

if age in(90..100] then result not specified
if age in(50..60) then result not specified
if age in[-2..0) then result not specified
if age<=-4 then result not specified

NOTE Test cases are generated only for:

  1. variables explicitly declared as inputs to the decision.
  2. values of those variables that are actually tested in the rules

Once you add rules for all the missing cases the number of test cases may increase significantly.

Also by (temporarily) reducing the number of declared input variables you can limit the test data to a single table or subset of the tables.