Sunday, September 19, 2010

Extract All Cases from Requirement using Cause and Effect Analysis Technique

Extract All Cases from Requirement using Cause and Effect Analysis Technique

Introduction:

This article describe in details an organized method to extract all possible cases from the requirement , this can help the system analyst in defining all the cases and also can help developers while preparing the unit TCs and of course will help the testers to write unified test cases.

First of all suppose you have the following requirement:

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’ gets a special paragraph added with an offer to subscribe to another level of discounting.

The problem is if you give this requirement to any 4 different testers, the 4 will produce different no of TCs, I will explain how to derive a unify number of TCs using cause and effect analysis and decision table.


Step 1: Break the specification down to cause and effect:

First the analyst must break down the requirement to causes and effects

Cause: is a distinct input condition or an equivalence class of input conditions (the cause which trigger the effect) in our above example Customer Type (A,B,C, Other) is a cause

Effect: is an output condition. Determine the logical relationship between the cause and the effects , in our above example “Get a normal letter” is an effect for the cause customer type(A,B,C, Other )
Usually the effects is an output action (Ex. Error message , application action , executing specific application job , etc…)

After this step you should have cause and effects like that:

C1: Customer Type A,B,C, Other

C2: 2 or more lines

C3: Credit Rating

E1: Normal Letter

E2: Special Letter

E4: Add special paragraph

E5: Get Normal letter

Step 2: Put Causes and Effects in the decision Table.

Then we should fill the decision table by putting the cause and the effects together in that table as a following:

Cause\Effect

C1:

C2:

C3:

E1:

E2:

E3:

E4:

E5:

Step 3: Calculate all possible Combinations

This is very important step to know no of columns in our decision table, simply use this formula to know all no of combinations that can be occur:

If all causes are simply Y/N values:
2number of causes

If 1 cause with 3 values and 3 with 2:
31 * 23 = 24

In our example, C1 has 4 values (A or B or C or Other) AND C2 has 2 values (YES or NO) also C3 has 2 values (YES or NO) so our formula should be :

14 * 22 = 16 combinations

So we should draw for the decision table 16 columns which present 16 different combinations.

Now the table should be like that:

Cause\Effect

C1:

C2:

C3:

E1:

E2:

E3:

E4:

E5:

Step 4: Fill Columns

We can fill columns 2 methods:

1- Logical method: in this method you start filling column by column , start with the causes and end up with the effect (put into consideration that every column is a case).

2- Repeating Factor Algorithm method:

a. Determine Repeating Factor (RF): divide remaining combinations by the number of possible values for that cause

b. Write RF times the first value, then RF times the next etc. until row is full

Example for using Repeating Factor Algorithm: suppose you have the following decision table:

1

2

3

4

5

6

7

8

C1(Y\N)

C2(Y\N)

C3(Y\N)

E1

E2

Fill first row: RF = number of remaining combination (8) / possible value for this

Cause (2) = (8/2 = 4) , so we will fill 4 from Y and 4 of N , the DT will be :

1

2

3

4

5

6

7

8

C1(Y\N)

Y

Y

Y

Y

N

N

N

N

C2(Y\N)

C3(Y\N)

E1

E2

Fill Second row: RF = number of remaining combination (4) / possible value for this

Cause (2) = (4/2 = 2) , so we will fill 2 from Y and 2 of N , the DT will be :

1

2

3

4

5

6

7

8

C1(Y\N)

Y

Y

Y

Y

N

N

N

N

C2(Y\N)

Y

Y

N

N

Y

Y

N

N

C3(Y\N)

E1

E2

Fill Third row: RF = number of remaining combination (2) / possible value for this

Cause (2) = (2/2 = 1) , so we will fill 1 from Y and 1 of N , the DT will be :

1

2

3

4

5

6

7

8

C1(Y\N)

Y

Y

Y

Y

N

N

N

N

C2(Y\N)

Y

Y

N

N

Y

Y

N

N

C3(Y\N)

Y

N

Y

N

Y

N

Y

N

E1

E2

Filing DT in example1:

In example 1 we have 3 causes and 5 effects with total number of combinations = 16 combinations

Fill first row: RF = number of remaining combination (16) / possible value for this

Cause (4) = (16/4 = 4) , so we will fill 4 from every type (A,B,C,O) , the DT will be :

Cause\Effects

C1(A,B,C,O)

A

A

A

A

B

B

B

B

C

C

C

C

O

O

O

O

C2(Yes\No)

C3(yes\No)

E1

E2

E3

E4

E5


Fill Second row: RF = number of remaining combination (2*2) / possible value for this

Cause (2) = (4/2 = 2) , so we will fill 2 from every Y and 2 from N , the DT will be :

Cause\Effects

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

C1(A,B,C,O)

A

A

A

A

B

B

B

B

C

C

C

C

O

O

O

O

C2(Yes\No)

Y

Y

N

N

Y

Y

N

N

Y

Y

N

N

Y

Y

N

N

C3(yes\No)

E1

E2

E3

E4

E5

Fill Third row: RF = number of remaining combination (2) / possible value for this

Cause (2) = (2/2 = 1) , so we will fill 1 from every Y and 1 from N , the DT will be :

Cause\Effects

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

C1(A,B,C,O)

A

A

A

A

B

B

B

B

C

C

C

C

O

O

O

O

C2(Yes\No)

Y

Y

N

N

Y

Y

N

N

Y

Y

N

N

Y

Y

N

N

C3(yes\No)

Y

N

Y

N

Y

N

Y

N

Y

N

Y

N

Y

N

Y

N

E1

E2

E3

E4

E5


Step 5: Reduce Combinations

1- In our simple example find a don’t care “-” sign and place it ,

1

2

3

4

5

6

7

8

C1(Y\N)

Y

Y

Y

Y

N

N

N

N

C2(Y\N)

Y

Y

N

N

Y

Y

N

N

C3(Y\N)

Y

N

Y

N

Y

N

Y

N

E1

E2

In the above DT suppose in column 3 and column 4 , when the C2 become “N” the program end , so we will put in C3 the sign “-” which mean done care , the DT will become as follow :

1

2

3

4

5

6

7

8

C1(Y\N)

Y

Y

Y

Y

N

N

N

N

C2(Y\N)

Y

Y

N

N

Y

Y

N

N

C3(Y\N)

Y

N

-

-

Y

N

-

-

E1

E2

2- After placing the “-” don’t care sign , now remove the repeated columns , column 3 and 4 now become identical so will remove one of them , also column 7 and 8 now identical so I will remove one of them too , so the DT will be :

1

2

3

5

6

8

C1(Y\N)

Y

Y

Y

N

N

N

C2(Y\N)

Y

Y

N

Y

Y

N

C3(Y\N)

Y

N

-

Y

N

-

E1

E2

After removing the columns you must do a checksum for the table to assure that the DT still

cover all the original combination = 8

To do checksum:

For each column calculate the 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

So the check sum will be as follow:

1

2

3

5

6

8

C1(Y\N)

Y

Y

Y

N

N

N

C2(Y\N)

Y

Y

N

Y

Y

N

C3(Y\N)

Y

N

-

Y

N

-

E1

E2

Checksum

1

1

2

1

1

2

8

Step 6: Add effects to table

Read column by column and determine the effects

One effect can occur in multiple test combinations

Cause\Effects

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

C1(A,B,C,O)

A

A

A

A

B

B

B

B

C

C

C

C

O

O

O

O

C2(Yes\No)

Y

Y

N

N

Y

Y

N

N

Y

Y

N

N

Y

Y

N

N

C3(yes\No)

Y

N

Y

N

Y

N

Y

N

Y

N

Y

N

Y

N

Y

N

E1: Normal letter

X

X

X

X

X

X

X

X

?

?

?

?

E2: Special Letter

X

X

X

X

?

?

?

?

E3: Add paragraph

?

X

X

?

X

X

?

X

X

?

?

?

?

E4: No Letter

Checksum

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

16

As we see in the above table after adding effects to the table you can:

1- Determine if you have missing requirement or not as the case we place “?” , the requirement is missing if the customer type is other than the 3 types A,B,C

2- You can determine if there is a redundant requirement , example in the column 6 and 7 by looking into the table you will find the 2 columns has the same effects , so you can ask the client or the analyst about this situation and if it doesn’t matter to have credit line or not in case of customer type B

3- Finally you will be sure that you cover all possible scenarios by doing this analysis.