Test Cases For Numeric Conditions - Gnorion/BizVR GitHub Wiki

Test Cases For Numeric Conditions

Given these rules

R1 RGB1 Determine Price: if color = 'red' then price is 5    
R2 RGB1 Determine Price: if color = 'blue' and size = 'small' and shape = 'square' then price is 10    
R3 RGB1 Determine Price: if color = 'green' and shape = 'round' then price is 15    
R1 RGB2 Detemine Size: if length < 15 or  > 100 and width < 15 then size is 'large'    
R2 RGB2 Detemine Size: if length < 10 and width < 10 then size is 'small'    
R3 RGB2 Detemine Size: if length = 12 and width in [15..1000] then size is 'medium'    
R1 RGB3 Determine Color: if wavelength < 450 then color is 'UV'    
R2 RGB3 Determine Color: if wavelength in [450..495] then color is 'blue'    
R3 RGB3 Determine Color: if wavelength in (495..570] then color is 'green'    
R4 RGB3 Determine Color: if wavelength in (570..590] then color is 'yellow'    
R5 RGB3 Determine Color: if wavelength in [590..620] then color is 'orange'    
R6 RGB3 Determine Color: if wavelength in [620..750] then color is 'red'    
R1 RGB4 Determine Shipping: if price < 10 then shipping is 2    
R2 RGB4 Determine Shipping: if price > 10 then shipping is 5    
R1 RGB5 Determine Tax: if price < 12 then tax is 3    
R2 RGB5 Determine Tax: if price > 12 then tax is 5    

VV is now able to suggest 144 test cases like these. In parenthesis is the condition in the rule that was used to derive a suitable test value Total number of test case required = length 4 x width 3 x shape 2 x wavelength 6 = 144 (covers every possible combination) All other variables are derived from these by the rules

test case 1
shape = 'square' (= 'square')
length = 14 (< 15)
width = 14 (< 15)
wavelength = 449 (< 450)


test case 2
shape = 'square' (= 'square')
length = 14 (< 15)
width = 14 (< 15)
wavelength = 451 (in [450..495])


....... (141 more test cases)......


test case 144
shape = 'round' (= 'round')
length = 12 (= 12)
width = 16 (in [15..1000])
wavelength = 621 (in [620..750])

Still needs a bit more work but the basic structure is working.

ALTERNATIVES TO TESTING EVERY COMBINATION (which could be a huge number) Note an alternative testing strategy is to use less test cases but make sure every condition value is represented by at least one test.

Probably the better approach is to test each table separately, then the total number of test cases is the sum rather than the product. But we will have more variables - since to test each table requires us to define test values for the inputs to each table rather than to the entire decision. Table 1 color 3 x size 1 x shape 2= 6 Table 2 length 4 x width 3 = 12 Table 3 wavelength 6 = 6 Table 4 price 2 = 2 Table 5 price 2 = 2 Total test cases = 28 You might also need to add some tests for values that are not tested in the rules. But if there are values that are not tested then your rules are incomplete!!!!

It actually gets more complicated by the fact that the rules as stated above are incomplete and ambiguous. For example table 3 produces 6 different colors, but only 3 are actually tested in table 1 Table 1 produces a price of 10 but table 4 never tests that. Table 5 never tests if price is 12. But that value never gets set by any other rule. So really these are pretty awful rules and those issues should be fixed before worrying about testing it. BTW VV will flag all these issues for the user to fix.

⚠️ **GitHub.com Fallback** ⚠️