Unit Testing CSSE 376, Software Quality Assurance Rose-Hulman Institute of Technology March 27, 2007.

Slides:



Advertisements
Similar presentations
1 Software Unit Test Coverage And Test Adequacy Hong Zhu, Patrick A. V. Hall, John H.R. May Presented By: Arpita Gandhi.
Advertisements

Chapter 14 Testing Tactics
Marking Schema question1: 40 marks question2: 40 marks question3: 20 marks total: 100 marks.
Software Testing Testing.
White-Box Testing Techniques IV
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
1 Test Cases CSSE 376, Software Quality Assurance Rose-Hulman Institute of Technology March 13, 2007.
1 Static Analysis Methods CSSE 376 Software Quality Assurance Rose-Hulman Institute of Technology March 20, 2007.
White Box Testing and Symbolic Execution Written by Michael Beder.
Software Testing and Quality Assurance
Software Testing and Quality Assurance White Box Testing.
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
1 Software Testing and Quality Assurance Lecture 5 - Software Testing Techniques.
SOFTWARE TESTING WHITE BOX TESTING 1. GLASS BOX/WHITE BOX TESTING 2.
Topics in Software Dynamic White-box Testing: Data-flow Testing
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
System/Software Testing
Topics in Software Dynamic White-box Testing Part 2: Data-flow Testing
1 Software Testing Dr. Xin (Judy) Feng Web:
Software testing techniques Testing criteria based on data flow
CMSC 345 Fall 2000 Unit Testing. The testing process.
Chapter 12: Software Testing Omar Meqdadi SE 273 Lecture 12 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
© SERG Dependable Software Systems (Mutation) Dependable Software Systems Topics in Mutation Testing and Program Perturbation Material drawn from [Offutt.
Course Outline Traditional Static Program Analysis –Theory –Classic analysis and applications Points-to analysis, CHA, RTA –The Soot analysis framework.
White-Box Testing Techniques II Originals prepared by Stephen M. Thebaut, Ph.D. University of Florida Dataflow Testing.
Coverage – “Systematic” Testing Chapter 20. Dividing the input space for failure search Testing requires selecting inputs to try on the program, but how.
Introduction to Software Testing
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.
Test Drivers and Stubs More Unit Testing Test Drivers and Stubs CEN 5076 Class 11 – 11/14.
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.
Chapter 22 Developer testing Peter J. Lane. Testing can be difficult for developers to follow  Testing’s goal runs counter to the goals of the other.
Black-box Testing.
White-box Testing.
CS 217 Software Verification and Validation Week 7, Summer 2014 Instructor: Dong Si
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.
1 Program Testing (Lecture 14) Prof. R. Mall Dept. of CSE, IIT, Kharagpur.
Mutation Testing G. Rothermel. Fault-Based Testing White-box and black-box testing techniques use coverage of code or requirements as a “proxy” for designing.
SOFTWARE TESTING. INTRODUCTION Testing forms the first step in determining the errors in a program. It is the major quality control measure used during.
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
Software Testing Part II March, Fault-based Testing Methodology (white-box) 2 Mutation Testing.
08120: Programming 2: SoftwareTesting and Debugging Dr Mike Brayshaw.
Software Testing. System/Software Testing Error detection and removal determine level of reliability well-planned procedure - Test Cases done by independent.
Theory and Practice of Software Testing
Workshop on Integrating Software Testing into Programming Courses (WISTPC14:2) Friday July 18, 2014 Introduction to Software Testing.
Chapter 12: Software Testing Omar Meqdadi SE 273 Lecture 12 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
1 Test Coverage Coverage can be based on: –source code –object code –model –control flow graph –(extended) finite state machines –data flow graph –requirements.
Mutation Testing Breaking the application to test it.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 23, 1999.
Software Dynamic White-box Testing Part 2: Data-flow Testing Lecture 7 Prof. Mostafa Abdel Aziem Mostafa.
White-Box Testing Statement coverage Branch coverage Path coverage
Testing It is much better to have a plan when testing your programs than it is to just randomly try values in a haphazard fashion. Testing Strategies:
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
Software Testing. Software Quality Assurance Overarching term Time consuming (40% to 90% of dev effort) Includes –Verification: Building the product right,
PREPARED BY G.VIJAYA KUMAR ASST.PROFESSOR
Software TestIng White box testing.
White-Box Testing Techniques IV
Testing Tutorial 7.
Software Testing.
White-Box Testing Techniques IV
Data Coverage and Code Coverage
Structural testing, Path Testing
Types of Testing Visit to more Learning Resources.
White-Box Testing Techniques II
Software Testing (Lecture 11-a)
White-Box Testing Techniques II
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
White-Box Testing Techniques II
CSE 1020:Software Development
Software Testing.
Presentation transcript:

Unit Testing CSSE 376, Software Quality Assurance Rose-Hulman Institute of Technology March 27, 2007

2 Outline Role of unit testing Testing strategies Black box methods White box methods

3 Role of Unit Testing Assure minimum quality of units before integration into system Focus attention on relatively small units Marks end of development step

4 Testing versus Debugging TestingDebugging plannedunplanned results are recorded unrecorded may be done by non-developers always done by developers look for errorslook for causes of errors

5 Limits of Testing Testing can never demonstrate the absence of errors Exhaustive testing is infeasible Testing may be done imperfectly

6 Strategies for Unit Testing Black box use only specification of program test implementation against its specification White box use structure or other properties of a program to generate tests

7 Black Box Methods Equivalence partitioning Boundary value analysis

8 White Box Methods

9 Coverage statement branch path Cyclomatic Dataflow Mutation Error Based

10 Coverage Methods Statement execute each statement Branch execute each branch Path execute each path

11 Statement Coverage Execute each statement in the program Considered minimum criterion for most unit testing May be difficult to achieve for error cases

12 Example Program 1: if (a < 0) { 2: return 0 } 3: r = 0; 4: c = a; 5: while (c > 0) { 6: r = r + b; 7: c = c - 1; } 8: return r;

13 Statement Tests a = 3, b = 4 executes 1, 3, 4, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 8 a = -3, b = 2 executes 1, 2

14 Branch Coverage Execute each branch of the program at least once Differs from statement coverage only for "if" statements without "else"s and case statements without default cases.

15 Dataflow Testing More than branch coverage, but less than path coverage Uses information about references to variables to select paths

16 Definitions and Uses Defining node input statement lhs of assignment Usage node output statement rhs of assignment control statement

17 Suspicious Paths Variable is defined (set to a new value) but never referenced Variable is referenced but never defined Variable is defined twice before it is used

18 DU Paths Definition-use (du) path wrt V: a path containing a defining node for V at the beginning a usage node for V at the end, and no def's or use's in between DU testing: execute each du-path of each variable

19 Example Program 1: if (a < 0) { 2: return 0 } 3: r = 0; 4: c = a; 5: while (c > 0) { 6: r = r + b; 7: c = c - 1; } 8: return r;

20 Example DU Paths (corrected 3/28/07) Def (c) = {4, 7} Use (c) = {5, 7} Def (r) = {3, 6} Use (r) = {6, 8} du-paths for c: 4 - 5, 7 – 5 du-paths for r: , , ,

21 Test Cases for DU Paths (corrected 3/28/07) a = Covers du-paths: 4 - 5, 7 - 5, ,

22 Cartoon of the Day

23 Mutation Testing (As Applied to White-Box) Path testing exercises the control of a program, not the computations along the paths Most programs under test are "almost" right

24 Mutation Method 1.Pre-process program to generate mutants 2.Execute all the mutants and the original program 3.If a mutant differs from the original, then it is "killed" 4.If all mutants are killed, then test set is adequate.

25 Mutation Metaphor

26 Example Program function square( x: integer): integer; begin square := x * x end

27 Example Mutant function square( x: integer): integer; begin square := x + x end

28 Executing Mutants Test set {2} does not kill the mutant Test set {2, 4} does kill the mutant, and it reveals the flaw in the program

29 Which Mutants? Examples: Off by one errors (i+1, i, i-1) Different variable (i, j, k)

30 Assumptions of Mutation Testing Competent Programmer: The perfect program is very close to the program under test Oracle Hypothesis: You know the output for any input Continuity: Every complicated mistake can be caught by looking for simple mistakes.

31 Problems with Mutation Very expensive each test runs the whole program many mutants for every program Some mutants fail to halt May be difficult to detect when a mutant is really just an equivalent program Not reliable: may not try the right mutants