Logical coverage criteria

Source: Internet
Author: User

Most basic three

(1) predicate coverage (PC)

Each predicate shocould evaluate to both true and false.

(2) clause coverage (cc)

Each clause in predicate shoshould evaluate to both true and false.

(3) Combinatorial coverage (CBC)

All combinations of clause values shoshould be considered.

Let's use an example to initialize strate the idea.

Suppose we have Java code segment:
If (x <Y | flag) & list. Contains ("red") <br/>{< br/> // do something; <br/>}

We can abstract the predicate (x <Y | flag) & list. Contains ("red") to (A branch B) into C.

So predicate: P = (A then B) between C, and clses: A, B, and C.

(1) PC

Test Suite = {P = true, P = false}, we don't care about the values of A, B, C as long as P = true and P = false are satisfied.

(2) CC

In this case, a, B and c all have to evaluate to both true and false. The truth table is shown below.

 

A B C

-----------------------------

T

-----------------------------

F

-----------------------------

T

-----------------------------

F

-----------------------------

T

-----------------------------

F

-----------------------------

 

We do not care about the blank cells. So test suite = {(t, t, t), (F, F, F)} can satisfy CC.

 

(3) CBC

 

All combinations must be tested. So there will eight test cases.

 

A B C

-----------------------------

T

-----------------------------

T f

-----------------------------

T f t

-----------------------------

T f

-----------------------------

F t

-----------------------------

F t f

-----------------------------

F t

-----------------------------

F

-----------------------------

 

There are other more sophisticated coverage criteria to better test software.

 

Reference: Paul Ammann & Jeff Offutt "Introduction to software testing"

 

 

 

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.