Today’s Agenda  Quick Review  Finish Graph-Based Testing  Predicate Testing Software Testing and Maintenance 1.

Slides:



Advertisements
Similar presentations
Computer Science and Software Engineering University of Wisconsin - Platteville Note 5. Testing Yan Shi Lecture Notes for SE 3730 / CS 5730.
Advertisements

Introduction to Software Testing Chapter 3.3 Logic Coverage for Source Code Paul Ammann & Jeff Offutt
1 Applications of Optimization to Logic Testing Gary Kaminski and Paul Ammann ICST 2010 CSTVA Workshop.
Course Software Testing & Verification 2013/14 Wishnu Prasetya
Introduction to Software Testing Chapter 3.3 Logic Coverage from Source Code Paul Ammann & Jeff Offutt.
Paul Ammann & Jeff Offutt
Software Testing Logic Coverage. Introduction to Software Testing (Ch 3) © Ammann & Offutt 2 Logic Coverage Four Structures for Modeling Software Graphs.
Introduction to Software Testing Chapter 3.1, 3.2 Logic Coverage Paul Ammann & Jeff Offutt
Logic ChAPTER 3 1. Truth Tables and Validity of Arguments
CITS5501 Software Quality and Testing Logic and Path Coverage From Introduction to Software Testing, 2 nd ed, Ammann & Offutt.
Lecture 2 White-box Testing and Structural Coverage.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 5, 2005.
COMP 14 Introduction to Programming Miguel A. Otaduy May 20, 2004.
Introduction to Software Testing Chapter 3.1 Logic Coverage Paul Ammann & Jeff Offutt.
Introduction to Software Testing Chapter 8.2
COMP 110 Introduction to Programming Mr. Joshua Stough September 24, 2007.
Homework 3.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
Introduction to Software Testing Chapter 8.1 Logic Coverage Paul Ammann & Jeff Offutt
CSNB143 – Discrete Structure LOGIC. Learning Outcomes Student should be able to know what is it means by statement. Students should be able to identify.
Introduction to Software Testing Chapter 3.6 Disjunctive Normal Form Criteria Paul Ammann & Jeff Offutt
Today’s Agenda  Reminder: HW #1 Due next class  Quick Review  Input Space Partitioning Software Testing and Maintenance 1.
Boolean Algebra. Logical Statements A proposition that may or may not be true:  Today is Monday  Today is Sunday  It is raining.
Boolean Logic. Boolean Operators (T/F) xyx AND y FFF FTF TFF TTT xyx OR y FFF FTT TFT TTT xNOT x FT TF.
Introduction to Software Testing Chapter 3.1, 3.2 Logic Coverage Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapters 1-5 Coverage Summary Paul Ammann & Jeff Offutt
CS1022 Computer Programming & Principles Lecture 1 Logic and Proof.
Warmup Answer the following True/False questions in your head: I have brown hair AND I am wearing glasses I am male OR I am wearing sneakers I am NOT male.
Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.
Introduction to Software Testing Chapter 8.1 Logic Coverage Paul Ammann & Jeff Offutt
1 Input Space Partitioning(2). Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Chapter 4  Section 4.1  Section
Chapter 3 Object Interaction.  To construct interesting applications it is not enough to build individual objects  Objects must be combined so they.
Boolean Logic.
Using Logic Criterion Feasibility to Reduce Test Set Size While Guaranteeing Double Fault Detection Gary Kaminski and Paul Ammann Software Engineering.
Introduction to Software Testing Chapter 3.6 Disjunctive Normal Form Criteria Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 3.6 Disjunctive Normal Form Criteria Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 3.1 Logic Coverage Paul Ammann & Jeff Offutt.
MATH 110 Sec 12-1 Lecture: Intro to Counting Introduction to Counting: Just how many are there?
Introduction to Software Testing Chapter 3.2 Logic Coverage
Introduction to Software Testing (2nd edition) Chapter 5 Criteria-Based Test Design Paul Ammann & Jeff Offutt
Chapter 1 Logic and proofs
Introduction to Discrete Mathematics Lecture 1: Sep 6 AB C a = qb+r gcd(a,b) = gcd(b,r)
Introduction to Software Testing Chapter 8.2
Introduction to Software Testing Chapter 8.1 Logic Coverage
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 3, Sec# 1 & 2 Logic Coverage
Paul Ammann & Jeff Offutt
Software Testing and Maintenance 1
Introduction to Software Testing Syntactic Logic Coverage Criteria
Input Space Partition Testing CS 4501 / 6501 Software Testing
Introduction to Software Testing Chapter 3.1, 3.2 Logic Coverage
Logic Coverage CS 4501 / 6501 Software Testing
Boolean logic Taken from notes by Dr. Neil Moore
In-Class Extended Example Ch. 6.4
Paul Ammann & Jeff Offutt
Moonzoo Kim School of Computing KAIST
Introduction to Software Testing Chapter 3.2 Logic Coverage
Logic Coverage CS 4501 / 6501 Software Testing
Logic Coverage Active Clause Coverage CS 4501 / 6501 Software Testing
Logic Coverage from Source Code
Logic Coverage for Source Code CS 4501 / 6501 Software Testing
Boolean logic Taken from notes by Dr. Neil Moore
[Ammann and Offutt, “Introduction to Software Testing,” Ch. 8]
Introduction to Software Testing Chapter 8.1 Logic Coverage
Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 3.2 Logic Coverage
Introduction to Software Testing Chapter 3.1, 3.2 Logic Coverage
Presentation transcript:

Today’s Agenda  Quick Review  Finish Graph-Based Testing  Predicate Testing Software Testing and Maintenance 1

Quick Review  What is a definition? What is a use? Software Testing and Maintenance 2

Software Testing and Maintenance 3 Predicate Testing  Introduction  Basic Concepts  Predicate Coverage  Program-Based Predicate Testing  Summary

Software Testing and Maintenance 4 Motivation  Predicates are expressions that can be evaluated to a boolean value, i.e., true or false.  Many decision points can be encoded as a predicate, i.e., which action should be taken under what condition?  Predicate-based testing is about ensuring those predicates are implemented correctly.

Software Testing and Maintenance 5 Applications  Program-based: Predicates can be identified from the branching points of the source code  e.g.: if ((a > b) || c) { … } else { … }  Specification-based: Predicates can be identified from both formal and informal requirements as well as behavioral models such as FSM  “if the printer is ON and has paper then send the document for printing”  Predicate testing is required by US FAA for safety critical avionics software in commercial aircraft

Software Testing and Maintenance 6 Predicate Testing  Introduction  Basic Concepts  Predicate Coverage  Program-Based Predicate Testing  Summary

Software Testing and Maintenance 7 Predicate  A predicate is an expression that evaluates to a Boolean value  Predicates may contain:  Boolean variables  Non-boolean variables that are compared with the relational operators { , , , , ,  }  Boolean function calls  The internal structure is created by logical operators:  , , , , , 

Software Testing and Maintenance 8 Clause  A clause is a predicate that does not contain any of the logical operators  Example: (a = b)  C  p(x) has three clauses: a relational expression (a = b), a boolean variable C, and a boolean function call p(x)

Software Testing and Maintenance 9 Predicate Faults  An incorrect boolean operator is used  An incorrect boolean variable is used  Missing or extra boolean variables  An incorrect relational operator is used  Parentheses are used incorrectly

Software Testing and Maintenance 10 Example  Assume that (a d)  e is a correct boolean expression:  (a d)  e  (a d)  f  (a d)  (a = b)  (c > d)  e  (a = b)  (c  d)  e  (a d)  e

Software Testing and Maintenance 11 Predicate Testing  Introduction  Basic Concepts  Predicate Coverage  Program-Based Predicate Testing  Summary

Software Testing and Maintenance 12 Predicate Coverage  For each predicate p, TR contains two requirements: p evaluates to true, and p evaluates to false.  Example: ((a > b)  C)  p(x)) abCp(x) 154true 256false

Software Testing and Maintenance 13 Clause Coverage  For each clause c, TR contains two requirements: c evaluates to true, and c evaluates to false.  Example: ((a > b)  C)  p(x)) abCp(x) 154true 256false

Software Testing and Maintenance 14 Predicate vs Clause Coverage  Does predicate coverage subsume clause coverage? Does clause coverage subsume predicate coverage?  Example: p = a  b aba  b 1TTT 2TFT 3FTT 4FFF

Software Testing and Maintenance 15 Combinatorial Coverage  For each predicate p, TR has test requirements for the clauses in p to evaluate to each possible combination of truth values  Example: (a  b)  c abc(a  b)  c 1TTTT 2TTFF 3TFTT 4TFFF 5FTTT 6FTFF 7FFTF 8FFFF

Software Testing and Maintenance 16 Active Clause  The major clause is the clause on which we are focusing; all of the other clauses are minor clauses.  Typically each clause is treated in turn as a major clause  Determination: Given a major clause c in predicate p, c determines p if the minor clauses have values so that changing the truth value of c changes the truth value of p.  Note that c and p do not have to have the same value.  Example: p = a  b

Software Testing and Maintenance 17 Active Clause Coverage (ACC)  For each predicate p and each major clause c of p, choose minor clauses so that c determines p. TR has two requirements for each c: c evaluates to true and c evaluates to false.  Example: p = a  b ab Tf Ff fT fF c = a c = b

Software Testing and Maintenance 18 General Active Clause Coverage (GACC)  The same as ACC, and it does not require the minor clauses have the same values when the major clause evaluates to true and false.  Does GACC subsume predicate coverage?

Software Testing and Maintenance 19 Correlated Active Clause Coverage (CACC)  The same as ACC, but it requires the entire predicate to be true for one value of the major clause and false for the other.  Example: a  b

Software Testing and Maintenance 20 CACC (2) abca  (b  c) 1TTTT 2TTFT 3TFTT 5FTTF 6FTFF 7FFTF  Example: a  (b  c)

Software Testing and Maintenance 21 Restricted Active Clause Coverage (RACC)  The same as ACC, but it requires the minor clauses have the same values when the major clause evaluates to true and false.  Example: a  (b  c) abca  (b  c) 1TTTT 5FTTF 2TTFT 6FTFF 3TFTT 7FFTF

Software Testing and Maintenance 22 CACC vs RACC (1)  Consider a system with a valve that might be either open or closed, and several modes, two of which are “operational” and “standby”.  Assume the following two constraints: (1) The valve must be open in “operational” and closed in all other modes; (2) The mode cannot be both “operational” and “standby” at the same time.  Let a = “The valve is closed”, b = “The system status is operational”, and c = “The system status is standby”. Then, the two constraints can be formalized as (1)  a  b; (2)  (b  c)

Software Testing and Maintenance 23 CACC vs RACC (2) abc(a  b)  cConstraints violated 1TTTT1 & 2 2TTFT1 3TFTT 4TFFF 5FTTF2 6FTFF 7FFTF1 8FFFF1  Suppose that a certain action can be taken only if the valve is closed and the system status is in Operational or Standby, i.e., a  (b  c)

Software Testing and Maintenance 24 Inactive Clause Coverage (ICC)  A complementary criterion to ACC that ensures that the major clause that should NOT affect the predicate does NOT, in fact, affect the predicate.  For each predicate p and each major clause c of p, choose minor clauses so that c does not determine p. TR has four requirements for each clause c: (1) c evaluates to true with p = true; (2) c evaluates to false with p = true; (3) c evaluates to true with p = false; and (4) c evaluates to false with p = true.

Software Testing and Maintenance 25 GICC & RICC  GICC does not require the values of the minor clauses to be the same when the major clause evaluates to true and false.  RICC requires the values the minor clauses to be the same when the major clause evaluates to true and false.

Software Testing and Maintenance 26 Making Active Clauses  Let p be a predicate and c a clause. Let p c=true (or p c=false ) be the predicate obtained by replacing every occurrence of c with true (or false)  The following expression describes the exact conditions under which the value of c determines the value of p: p c = p c=true  p c=false

Software Testing and Maintenance 27 Example (1)  Consider p = a  b and p = a  b.

Software Testing and Maintenance 28 Example (2)  Consider p = a  b  a   b.

Software Testing and Maintenance 29 Example (3)  Consider p = a  (b  c).

Software Testing and Maintenance 30 Finding Satisfying Values  How to choose values that satisfy a given coverage goal?

Software Testing and Maintenance 31 Example (1)  Consider p = (a  b)  c: ax < y bdone cList.contains(str) How to choose values to satisfy predicate coverage?

Software Testing and Maintenance 32 Example (2) abcp 1tttt 2ttff 3tftt 4tfff 5fttt 6ftff 7fftf 8ffff {1, 3, 5}  {2, 4, 6, 7, 8}

Software Testing and Maintenance 33 Example (3)  Suppose we choose {1, 2}. a bc x = 3 y = 5done = trueList = [“Rat”, “cat”, “dog”] str = “cat” x = 0, y = 7done = trueList = [“Red”, “White”] str = “Blue”

Software Testing and Maintenance 34 Example (4)  What about clause coverage?

Software Testing and Maintenance 35 Example (5)  What about GACC, CACC, and RACC?

Software Testing and Maintenance 36 Predicate Testing  Introduction  Basic Concepts  Predicate Coverage  Program-Based Predicate Testing  Summary

Software Testing and Maintenance 37 Reachability & Controllability  Reachability: A test must be able to reach the predicate being tested.  Controllability: Internal variables must be rewritten in terms of external input variables  In general, finding values to satisfy reachability and controllability is undecidable.

Software Testing and Maintenance 38 TriType 1 // Jeff Offut – Java version Feb // The old standby: classify triangles 3 import java.io.*; 4 5 class trityp 6 { 7 private static String[] triTypes = { "", // Ignore 0. 8 "scalene", "isosceles", "equilateral", "not a valid triangle"}; 9 private static String instructions = "This is the ancient TriTyp program.\nEnter three integers that represent the lengths of the sides of a triangle.\nThe triangle will be categorized as either scalene, isosceles, equilateral\nor invalid.\n"; public static void main (String[] argv) 12 { // Driver program for trityp 13 int A, B, C; 14 int T; 16 System.out.println (instructions); 17 System.out.println ("Enter side 1: "); 18 A = getN(); 19 System.out.println ("Enter side 2: "); 20 B = getN(); 21 System.out.println ("Enter side 3: "); 22 C = getN(); 23 T = Triang (A, B, C); System.out.println ("Result is: " + triTypes [T]); 26 } // ==================================== 29 // The main triangle classification method 30 private static int Triang (int Side1, int Side2, int Side3) 31 { 32 int tri_out; // tri_out is output from the routine: 35 // Triang = 1 if triangle is scalene 36 // Triang = 2 if triangle is isosceles 37 // Triang = 3 if triangle is equilateral 38 // Triang = 4 if not a triangle // After a quick confirmation that it's a legal 41 // triangle, detect any sides of equal length 42 if (Side1 <= 0 || Side2 <= 0 || Side3 <= 0) 43 { 44 tri_out = 4; 45 return (tri_out); 46 } 48 tri_out = 0; 49 if (Side1 == Side2) 50 tri_out = tri_out + 1; 51 if (Side1 == Side3) 52 tri_out = tri_out + 2; 53 if (Side2 == Side3) 54 tri_out = tri_out + 3; 55 if (tri_out == 0) 56 { // Confirm it's a legal triangle before declaring 57 // it to be scalene if (Side1+Side2 <= Side3 || Side2+Side3 <= Side1 || 60 Side1+Side3 <= Side2) 61 tri_out = 4; 62 else 63 tri_out = 1; 64 return (tri_out); 65 } 67 /* Confirm it's a legal triangle before declaring */ 68 /* it to be isosceles or equilateral */ if (tri_out > 3) 71 tri_out = 3; 72 else if (tri_out == 1 && Side1+Side2 > Side3) 73 tri_out = 2; 74 else if (tri_out == 2 && Side1+Side3 > Side2) 75 tri_out = 2; 76 else if (tri_out == 3 && Side2+Side3 > Side1) 77 tri_out = 2; 78 else 79 tri_out = 4; 80 return (tri_out); 81 } // end Triang

Software Testing and Maintenance 39 Predicates 42: (Side1 <= 0 || Side2 <= 0 || Side3 <= 0) 49: (Side1 == Side2) 51: (Side1 == Side3) 53: (Side2 == Side3) 55: (triOut == 0) 59: (Side1+Side2 <= Side3 || Side2+Side3 <= Side1 || Side1+Side3 <= Side2) 70: (triOut > 3) 72: (triOut == 1 && Side1+Side2 > Side3) 74: (triOut == 2 && Side1+Side3 > Side2) 76: (triOut == 3 && Side2+Side3 > Side1)

Software Testing and Maintenance 40 Reachability 42: True 49: P1 = s1>0 && s2>0 && s3>0 51: P1 53: P1 55: P1 59: P1 && triOut = 0 62: P1 && triOut = 0 && (s1+s2 > s3) && (s2+s3 > s1) && (s1+s3 > s2) 70: P1 && triOut != 0 72: P1 && triOut != 0 && triOut <= 3 74: P1 && triOut != 0 && triOut <= 3 && (triOut !=1 || s1+s2<=s3) 76: P1 && triOut != 0 && triOut <= 3 && (triOut !=1 || s1+s2<=s3) && (triOut !=2 || s1+s3<=s2) 78: P1 && triOut != 0 && triOut <= 3 && (triOut !=1 || s1+s2<=s3) && (triOut !=2 || s1+s3 <= s2) && (triOut !=3 || s2+s3 <= s1)

Software Testing and Maintenance 41 Solving Internal Vars At line 55, triOut has a value in the range (0.. 6) triOut = 0 s1!=s2 && s1!=s3 && s2!=s3 1 s1=s2 && s1!=s3 && s2!=s3 2 s1!=s2 && s1=s3 && s2!=s3 3 s1!=s2 && s1!=s3 && s2=s3 4 s1=s2 && s1!=s3 && s2=s3 5 s1!=s2 && s1=s3 && s2=s3 6 s1=s2 && s1=s3 && s2=s3

Software Testing and Maintenance 42 Reduced Reachability 42: True 49: P1 = s1>0 && s2>0 && s3>0 51: P1 53: P1 55: P1 59: P1 && s1 != s2 && s2 != s3 && s2 != s3 (triOut = 0) 62: P1 && s1 != s2 && s2 != s3 && s2 != s3 (triOut = 0) && (s1+s2 > s3) && (s2+s3 > s1) && (s1+s3 > s2) 70: P1 && P2 = (s1=s2 || s1=s3 || s2=s3) (triOut != 0) 72: P1 && P2 && P3 = (s1!=s2 || s1!=s3 || s2!=s3) (triOut <= 3) 74: P1 && P2 && P3 && (s1 != s2 || s1+s2<=s3) 76: P1 && P2 && P3 && (s1 != s2 || s1+s2<=s3) && (s1 != s3 || s1+s3<=s2) 78: P1 && P2 && P3 && (s1 != s2 || s1+s2<=s3) && (s1 != s3 || s1+s3<=s2) && (s2 != s3 || s2+s3<=s1)

Software Testing and Maintenance 43 Predicate Coverage TrueFalse PredicateABCEOABC P42:(Side1 <= 0 || Side2 <= 0 || Side3 <= 0) P49:(Side1 == Side2) P51:(Side1 == Side3) P53:(Side2 == Side3) P55:(triOut == 0) P59:(Side1+Side2 <= Side3 || Side2+Side3 <= Side1 || Side1+Side3 <= Side2) P70:(triOut > 3) P72:(triOut == 1 && Side1+Side2 > Side3) P74:(triOut == 2 && Side1+Side3 > Side2) P76:(triOut == 3 && Side2+Side3 > Side1)

Software Testing and Maintenance 44 Clause Coverage TrueFalse PredicateABCEOABC P42:(Side1 <= 0) (Side2 <= 0) (Side3 <= 0) P59:(Side1+Side2 <= Side3) (Side2+Side3 <= Side1) (Side1+Side3 <= Side2) P72:(triOut == 1) (Side1+Side2 > Side3) P74:(triOut == 2) (Side1+Side3 > Side2) P76:(triOut == 3) (Side2+Side3 > Side1)

Software Testing and Maintenance 45 CACC Coverage PredicateClausesABCEO P42:(Side1 <= 0)Tff0114 (Side2 <= 0)Fff1113 (Side3 <= 0)fTf1014 ffT1104 P59:(Side1+Side2 <= Side3)Tff2364 (Side2+Side3 <= Side1)Fff2341 (Side1+Side3 <= Side2)fTf6234 ffT2634 P72:(triOut == 1)Tt-2232 (Side1+Side2 > Side3)Ft-2332 tF-2254 P74:(triOut == 2)Tt-2322 (Side1+Side3 > Side2)Ft-2332 tF-2524 P76:(triOut == 3)Tt-3222 (Side2+Side3 > Side1)Ft-3634 tF-5224

Software Testing and Maintenance 46 Predicate Testing  Introduction  Basic Concepts  Predicate Coverage  Program-Based Predicate Testing  Summary

Software Testing and Maintenance 47 Subsumption CoC RACC CACC GACC CC PC RICC GICC

Software Testing and Maintenance 48 Recap  Predicate testing is about ensuring that each decision point is implemented correctly.  If we flip the value of an active clause, we will change the value of the entire predicate.  Different active clause criteria are defined to clarify the requirements on the values of the minor clauses.  Reachability and controllability are two practical challenges that have to be met when we apply predicate testing to programs.