White box testing logic coverage: predicate coverage, clause coverage, three types of valid word and sentence coverage and other knowledge points

This note will simplify the concepts in the book and explain them in an easy-to-understand way. Some examples are difficult to type, so I will just put pictures!

Table of contents

Basic knowledge:

predicate coverage predicate coverage

clause coverageclause coverage

combinatorial coverage

Active Clause Coverage

General Active Clause Coverage

Correlated Active Clause Coverage

Restricted Active Clause Coverage


Basic knowledge:

Predicate predicate : an expression whose result is a Boolean value, internally connected with logical operators (V, ^, —>, etc.).

eg:(a>b) v (C) ^P(x)

Clause : a predicate that does not contain any logical operators

eg: Predicate ((a = b) VC) ^ P(x) contains three clauses: (a = b), C, P(x)

predicate coverage predicate coverage

Also known as decision coverage, it requires that for a set of predicates, TR (Test request) includes the results of each predicate as true and false.

eg:

clause coverageclause coverage

Also known as conditional coverage, it requires that for each clause in each predicate, TR includes whether the result of that clause is true or false.

eg: For the predicate ((a = b) VC) ^ P(x), to satisfy CC, (a=b) needs to get T and F respectively, C can get T and F respectively, and P(x) can get T respectively. and F. These two sets of test cases are sufficient, and I won’t go into details.

combinatorial coverage

Also known as decision coverage, TR requires that for each clause in each predicate, TR include every possible combination of true and false results of the clause. (That is, on the basis of word coverage, different combinations need to exist)

eg: Known predicate (a V b) ^ c

Satisfies clause coverage:

a b c
1 T T T
2 F F F

Satisfy combination coverage:

a b c
1 T T T
2 F T T
3 T F T
4 T T F
5 F F T
6 T F F
7 F T F
8 F F F

Active Clause Coverage

For each predicate in the predicate group, select the main clause Ci from the clauses in the predicate, and the rest are secondary clauses Cj. TR includes Ci for true and Ci for false. (It’s not easy to understand, so I suggest you understand it carefully!)

Note: What is the main clause ? For example: For example, if the predicate a ^ b, b takes T, then if a takes T, the entire expression value is T, if a takes F, the entire expression value is F, then a is the main clause, because its The value determines the TF of the entire predicate, and b is the secondary clause.

Another example is the predicate a V b. If b takes F, then if a takes T, the entire expression value is T. If a takes F, the entire expression value is F. a is the main clause, because its value determines TF of the entire predicate, b is the secondary clause.

The above is the case where a is selected as the main clause. For effective clause coverage, each clause must be called a main clause, and if it is called a main clause, the value of the secondary clause must be determined first !

For effective word coverage, the following three different forms are extended (examples are at the bottom):

General Active Clause Coverage

Each main clause is required to be true or false, and the value of the secondary clause must ensure that the main clause determines the result of the predicate (but it does not require the same), and the value of the secondary clause does not have to be the same.

Correlated Active Clause Coverage

On the basis of broad effective clause coverage, it is also required that the predicate must contain true and false results. (In many cases, for predicate p, GACC and CACC are the same. They use the same test input pair, both including T and F, but they do not represent GACC=CACC, such as predicate p=a<->b, regardless of Whatever the true value of b is, a determines p, and the result of p is always true.)

Restricted Active Clause Coverage

On the basis of the coverage of relevant valid words, when taking T and F for the main clause, the secondary clauses are required to have the same value.

eg1: For the predicate (a V b) ^ c, find GACC, CACC, RACC

TR(GACC)={ (a=True^Pa,a=False^Pa), (b=True^Pb,b=False^Pb), (b=True^Pb,b=False^Pb)}

The truth table listed is:

serial number a b c (a V b) ^ c
a is the main clause 1 T f t t
2 F f t f
b is the main clause 3 f T t t
4 f F t f
c is the main clause 5 t f T t
6 f t F f
7 t f F f
8 f t T t
9 t t T t
10 t t F f

Obviously, 1-6 can satisfy GACC when abc is the main clause respectively. Remove duplicates: 1 and 5 are repeated, 2 and 4 are repeated, and only one is retained. Therefore, there are four final test cases that satisfy GACC: 1, 2, 3, 6.

After analysis, it can be seen that each of the above test cases that satisfy GACC contains the values ​​of T and F for p, so the above test cases that satisfy GACC also happen to satisfy CACC.

For RACC, when a is the main clause, 1 and 2 are satisfied; when b is the main clause, 3 and 4 are satisfied; when c is the main clause, there are three groups that are satisfied: 6 and 8, 5 and 7, and 9 and 10.

It is not easy to make. If it is helpful to you, please like and save it. If you have any questions, please leave a message~

Guess you like

Origin blog.csdn.net/weixin_46019681/article/details/125013689