Decision Tables A useful testing technique and more… Marien de Wilde, Solution Architect In this session … Definition Application areas Steps to create a decision table Exercise Solution to exercise February 2010 2 Definition Causes Cause 1 Cause 2 Cause 3 Effects Effect 1 Effect 2 Combinations Values 1 2 3 4 5 6 7 8 Y, N Y Y Y Y NNNN Y, N Y Y NNY Y NN Y, N Y NY NY NY N X X X February 2010 X X X Components A decision table lists causes and effects in a matrix. Each column represents a unique combination. Purpose is to structure logic Cause = condition Effect = action = expected results 3 Application Areas Business Analysis Programming Testing Hardware Design etc February 2010 4 Steps to Create a decision table 1. List all causes in the decision table 2. Calculate the number of possible combinations 3. Fill columns with all possible combinations 4. Reduce test combinations 5. Check covered combinations 6. Add effects to the table February 2010 5 Step 1: List all causes Causes Cause 1 Cause 2 Cause 3 Effects Effect 1 Effect 2 February 2010 Values Y, N Y, N Y, N Hints: Combinations 1 2 3 4 5 6 7 8Write down the values Y Y Y Y NNNN Y Y N N Y Y N Nthe cause/condition Y NY NY NY N can assume X X XCluster related causes X X X Put the most dominating cause first Put multi valued causes last 6 Step 2: Calculate combinations Number of Values to If all causes are simply Y/N the power of the values: number of causes 2number of causes with these values If 1 cause with 3 values and 3 with 2: 31 * 23 = 24 February 2010 Or, use the Values column and multiply each value down the column, eg. 3*2*2*2=24 7 es e1 e2 e3 ts t1 t2 Step 3: Fill columns Combinations Values 1 2 3 4 5 6 7 8 Y, N Y Y Y Y NNNN Y, N Y Y NNY Y NN Y, N Y NY NY NY N X X X X X X February 2010 Algorithm: 1. Determine Repeating Factor (RF): divide remaining combinations by the number of possible values for that cause 2. Write RF times the first value, then RF times the next etc. until row is full 3. Next row, go to 1. 8 Step 4: Reduce combinations Causes Cause 1 Cause 2 Cause 3 Effects Effect 1 Effect 2 Causes Cause 1 Cause 2 Cause 3 Effects Effect 1 Effect 2 February 2010 Combinations Values 1 2 3 4 5 6 7 8 Y, N Y Y Y Y NNNN Y, N Y Y NNY Y NN Y, N Y N - - Y NY N X X X X X X Combinations Values 1 2 3 4 5 6 7 Y, N Y Y Y NNNN Y, N Y Y NY Y NN Y, N Y N - Y NY N X X X Find indifferent combinations – place a ‘-’ X X Join columns where columns are identical Tip: ensure the effects are the same 9 Step 5: Check covered combinations Checksum Causes Cause 1 Cause 2 Cause 3 Effects Effect 1 Effect 2 Checksum Combinations Values 1 2 3 4 Y, N Y Y Y N Y, N Y N N Y, N - Y N - February 2010 X 2 For each column calculate the X 1 1 4 8 combinations it represents A ‘-’ represents as many combinations as the cause has Multiply for each ‘-’ down the column Add up total and compare with step 2 10 Step 6: Add effects to table Causes Cause 1 Cause 2 Cause 3 Effects Effect 1 Effect 2 Checksum Combinations Values 1 2 3 4 Y, N Y Y Y N Y, N Y N N Y, N - Y N - February 2010 X X 2 X X 1 1 4 Read column by column and determine the effects One effect can occur in multiple test 8 combinations 11 Exercise: Specification Create a decision table A mailing is to be sent out to customers. The content of the mailing is about the current level of discounting and potential levels of discounting. The content is different for different types of customers. Customer Types A, B and C get a normal letter except Customer Type C, who get a special letter. Any customer with 2 or more current lines or with a credit rating of ‘X’ get a special paragraph added with an offer to subscribe to another level of discounting. February 2010 12 Solution on next slide February 2010 13 Exercise: possible solution Causes Customer Type 2 or more lines Credit rating = X Effects Normal Letter Special Letter Add. Paragraph No Letter Checksum Values A,B,C,O Y, N Y, N 1 A Y Y 2 A Y N 3 A N Y 4 A N N 5 B Y Y 6 B Y N Combinations 7 8 9 10 11 12 B B C C C C N N Y Y N N Y N Y N Y N X X X X X X X X ? X X ? X X X X X X ? X X 1 1 1 1 1 1 1 1 1 1 1 1 13 O Y Y 14 O Y N 15 O N Y 16 O N N ? ? ? ? 1 ? ? ? ? 1 ? ? ? ? 1 ? ? ? ? 1 16 “2 or more current lines OR credit rating X”. What if both: AND? Other customer types? See “O-Other” above. What about non current lines? February 2010 14 Thank You February 2010 15