White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 111 W. Eric Wong Department of Computer Science The.

Slides:



Advertisements
Similar presentations
Lecture 2: testing Book: Chapter 9 What is testing? Testing is not showing that there are no errors in the program. Testing cannot show that the program.
Advertisements

Formal Methods and Testing Goal: software reliability Use software engineering methodologies to develop the code. Use formal methods during code development.
Testing and Quality Assurance
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
Unit Testing CSSE 376, Software Quality Assurance Rose-Hulman Institute of Technology March 27, 2007.
Informatics 43 – May 5, Restatement of goals Want to verify software’s correctness  Need to test  Need to decide on test cases  No set of test.
Informatics 43 – April 30, What is a test case? An input to a system, and the correct output. An “input” may be complex. Example: – What is an input.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 16, 1999.
Software Testing and Quality Assurance
IMSE Week 18 White Box or Structural Testing Reading:Sommerville (4th edition) ch 22 orPressman (4th edition) ch 16.
Software Testing and Quality Assurance
Chapter 18 Testing Conventional Applications
1 Software Testing and Quality Assurance Lecture 5 - Software Testing Techniques.
SOFTWARE TESTING WHITE BOX TESTING 1. GLASS BOX/WHITE BOX TESTING 2.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
CPIS 357 Software Quality & Testing
CMSC 345 Fall 2000 Unit Testing. The testing process.
EGR 2261 Unit 5 Control Structures II: Repetition  Read Malik, Chapter 5.  Homework #5 and Lab #5 due next week.  Quiz next week.
1 Testing Course notes for CEN Outline  Introduction:  terminology and philosophy  Factors that influence testing  Testing techniques.
Coverage – “Systematic” Testing Chapter 20. Dividing the input space for failure search Testing requires selecting inputs to try on the program, but how.
1 Reducing Cost of Regression Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 11 Reduce Cost of Regression Testing W. Eric Wong.
Requirements-based Test Generation for Functional Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 1 W. Eric Wong Department.
Agenda Introduction Overview of White-box testing Basis path testing
1 Software Testing. 2 Path Testing 3 Structural Testing Also known as glass box, structural, clear box and white box testing. A software testing technique.
Software Testing Part I: Preliminaries Aditya P. Mathur Purdue University July 20-24, Technical Services Company Indianapolis. Graduate.
Testing Testing Techniques to Design Tests. Testing:Example Problem: Find a mode and its frequency given an ordered list (array) of with one or more integer.
Black Box Testing Techniques Chapter 7. Black Box Testing Techniques Prepared by: Kris C. Calpotura, CoE, MSME, MIT  Introduction Introduction  Equivalence.
Test Coverage CS-300 Fall 2005 Supreeth Venkataraman.
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
Summarizing “Structural” Testing Now that we have learned to create test cases through both: – a) Functional (blackbox)and – b) Structural (whitebox) testing.
Today’s Agenda  Reminder: HW #1 Due next class  Quick Review  Input Space Partitioning Software Testing and Maintenance 1.
1 Program Testing (Lecture 14) Prof. R. Mall Dept. of CSE, IIT, Kharagpur.
White Box Testing Arun Lakhotia University of Southwestern Louisiana P.O. Box Lafayette, LA 70504, USA
Test Case Designing UNIT - 2. Topics Test Requirement Analysis (example) Test Case Designing (sample discussion) Test Data Preparation (example) Test.
Computer Science 1 Systematic Structural Testing of Firewall Policies JeeHyun Hwang 1, Tao Xie 1, Fei Chen 2, and Alex Liu 2 North Carolina State University.
Theory and Practice of Software Testing
Agent program is the one part(class)of Othello program. How many test cases do you have to test? Reversi [Othello]
Dynamic Testing.
1 © 2011 Professor W. Eric Wong, The University of Texas at Dallas Requirements-based Test Generation for Functional Testing W. Eric Wong Department of.
1 Test Coverage Coverage can be based on: –source code –object code –model –control flow graph –(extended) finite state machines –data flow graph –requirements.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 23, 1999.
Foundations of Software Testing Chapter 7: Test Adequacy Measurement and Enhancement Using Mutation Last update: September 3, 2007 These slides are copyrighted.
Structural Coverage. Measurement of structural coverage of code is a means of assessing the thoroughness of testing. Such metrics do not constitute testing.
Informatics 43 – May 3, Restatement of goals Want to verify software’s correctness  Need to test  Need to decide on test cases  No set of test.
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
Functional testing, Equivalence class testing
Software TestIng White box testing.
Software Testing.
Software Testing.
Software Testing Day 1: Preliminaries
Cyclomatic complexity
Software Engineering (CSI 321)
Coverage-Based Test Design CS 4501 / 6501 Software Testing
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 6 Domain Testing
Structural testing, Path Testing
Types of Testing Visit to more Learning Resources.
Testing Approaches.
Informatics 43 – May 3, 2016.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Software Testing (Lecture 11-a)
Structural Coverage.
Informatics 43 – April 28, 2016.
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Laboratory of Advanced Research on Software Technology
Structural Coverage.
Institute of Computing Tech.
Whitebox Testing.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Software Testing.
Unit III – Chapter 3 Path Testing.
Presentation transcript:

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 111 W. Eric Wong Department of Computer Science The University of Texas at Dallas White Box-based Coverage Testing

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 222 Speaker Biographical Sketch  Professor & Director of International Outreach Department of Computer Science University of Texas at Dallas  Vice President, IEEE Reliability Society  Secretary, ACM SIGAPP (Special Interest Group on Applied Computing)  Principal Investigator, NSF TUES (Transforming Undergraduate Education in Science, Technology, Engineering and Mathematics) Project: Incorporating Software Testing into Multiple Computer Science and Software Engineering Undergraduate Courses  Founder & Steering Committee co-Chair for the SERE conference (IEEE International Conference on Software Security and Reliability) (

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 3333 Two Techniques for Test Generation  Statement coverage  Decision coverage

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 4 Recent Issues in Software Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 4 Reducing the Cost of Program Debugging with Effective Software Fault Localization by Professor W. Eric Wong 4 Towards the Automation of Program Debugging by Vidroha Debroy 4 Preliminary

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 5555 Example I  How to search for stones inside a rectangular field? –We divide the entire field into smaller cells Stone

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 6666 Quiz  How should the field be divided?  How should we organize the search?

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 7777 Analogy  Field Program  Stone Program bug  Scan a cell Test program on one input  Find a stone Find a program bug  Partition Subset of input domain  Rectangle size Size of a partition (with respect to “Program”)

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 8888 Coverage Principle  The basic idea of coverage testing is that testing is complete when a well-defined set of tests is complete. –Example  Pilots use pre-flight check lists  Shoppers use grocery lists  To assure the correct completion of their tasks –In the same way testers can count the completed elements of a test plan  Examples  Requirements  Statements  Decisions

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 9999 The Role of Coverage in Testing  It provides a way of monitoring and measuring the progress of testing against explicit quantitative completion criteria –Gives a clear measure of the completion of the testing task –Example, for a computer program  Requirements  Statements  Decisions

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 10 What is Code Coverage Testing  It is “White Box Testing”  Takes into account the structure of the software being tested  Measures how thoroughly the code has been tested with respect to certain metrics

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 11  When test inputs are generated using program specifications, we say that we are doing functional testing –Functional testing tests how well a program meets the functionality requirements  These two types of testing are complementary –Basic functionalities should always be tested –The set of tests generated from function testing provides a good basis for code coverage testing 11 Code Coverage Testing versus Functional Testing

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 12 Importance of Code Coverage Testing  In general, a piece of code must be executed before a fault in it can be exposed  Helps early fault detection –Are system testers finding faults that should have been found and fixed by developers? –Relative cost of fixing a software fault

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 13 Statement Coverage

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 14 Statement Coverage: Computation  The statement coverage of a test set T with respect to (P, R) is computed as S c /(S e -S i ), where –S c is the number of statements covered, –S i is the number of infeasible (unreachable) statements, and –S e is the total number of executable statements in the program to be tested.  T is considered adequate with respect to the statement coverage criterion if the statement coverage of T with respect to (P, R) is 1 (i.e., 100%).

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 15 Statement Coverage: An Example

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 16 Statement Coverage: An Example (cont’d)  S e ={4, 5, 6, 7, 8, 9, 12, 13} Let T 1 ={t 1 :, t 2 : }  Statements covered: –t 1 : follow the red line –t 2 : follow the green line  S c =7, S i =1, S e =8. The statement coverage for T 1 is 7/(8 – 1)=1  Note that 9 is infeasible  Thus, we conclude that T 1 is adequate with respect to the statement coverage criterion. 16

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 17 Decision Coverage

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 18 Decision versus Simple Condition  A decision can be composed of a simple condition such as x<0, or of a more complex condition, such as (x<0 AND y<0).  A simple condition is considered covered if it evaluates to true and false in one or more executions of the program in which it occurs.  A compound condition is considered covered if each simple condition it is comprised of is also covered. 18 one decision & two simple conditions two decisions & two simple conditions

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 19 How to Cover a Decision?  A decision is considered covered if the flow of control has been diverted to all possible destinations that correspond to this decision, i.e., all outcomes of the decision have been taken.  This implies that, for example, the expression in the if or a while statement has evaluated to true in some execution of the program under test and to false in the same or another execution. –Examples  if (x < 0) {…..}  if ((x 0) {…..}  while (x < 3) {…..} 19

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 20 Decision Coverage: Computation  The decision coverage of a test set T with respect to (P, R) is computed as D c /(D e -D i ), where –D c is the number of decisions covered, –D i is the number of infeasible decisions, and –D e is the total number of decisions in the program to be tested.  T is considered adequate with respect to the decision coverage criterion if the decision coverage of T with respect to (P, R) is 1 (i.e., 100%). 20

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 21 Quiz  Consider the following program and a test set  Is T adequate with respect to decision coverage? 21

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 22 Statement Coverage versus Decision Coverage

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 23 A Program with a Bug  This following program inputs an integer x –if x < 0, transforms it into a positive value before invoking foo-1 to compute the output z –if x  0, compute z using foo-2 23 Where is the bug? There should have been an else clause for x  0 before this statement.

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 24 Is Statement Coverage Sufficient?  Consider a test set T={t 1 : }.  It is adequate with respect to statement coverage criterion, but does not reveal the bug. 24 There should have been an else clause for x  0 before this statement.

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 25 Is Decision Coverage Sufficient?  Consider another test set T'={t 1 : t 2 : }  T' is decision adequate, but not T.  Also, T' reveals the bug, but not T.  This example illustrates how and why decision coverage might help in revealing a bug that is not revealed by a test set adequate with respect to statement coverage. 25 There should have been an else clause for x  0 before this statement.

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 26 Statement Coverage versus Equivalence Class Partitioning

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 27 Example: Identify the Type of a Triangle (1)  A program P takes an input of three integers a, b and c, and returns the type of the triangle corresponding to three sides of length a, b, and c, respectively.  Quiz: How to generate a test set based on Equivalence Class Partitioning to achieve the highest statement coverage possible? 27

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 28 Example: Identify the Type of a Triangle (2)  Question: What is the statement coverage of your test set? 28

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 29 Decision Coverage versus Boundary Value Analysis

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 30 Complement between BVA and Decision Coverage  Test cases generated based on Boundary Value Analysis improve decision coverage.  Similarly, test cases that achieve high decision coverage also cover some boundary values.  Examples –If (x ≤ 0) {…..}  BVA: {x 1 = 0; x 2 = 1; x 3 = –1}  Together, x 1, x 2 and x 3 give 100% decision coverage –If (y = 3) {…..}  {y 1 = 3 and y 2 = a value different from 3} gives 100% decision coverage  At least one of the boundary values (y = 3) is covered 30

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 31 More Examples

White Box-based Coverage Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 32  Suds : A Coverage Testing Tool for C Programs