Testing, conclusion Based on material by Michael Ernst, University of Washington.

Slides:



Advertisements
Similar presentations
Identity and Equality Based on material by Michael Ernst, University of Washington.
Advertisements

Data-Flow Analysis Framework Domain – What kind of solution is the analysis looking for? Ex. Variables have not yet been defined – Algorithm assigns a.
CS412/413 Introduction to Compilers Radu Rugina Lecture 37: DU Chains and SSA Form 29 Apr 02.
Reasoning About Code; Hoare Logic, continued
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.
The Application of Graph Criteria: Source Code  It is usually defined with the control flow graph (CFG)  Node coverage is used to execute every statement.
Unit Testing CSSE 376, Software Quality Assurance Rose-Hulman Institute of Technology March 27, 2007.
CSE 331 SOFTWARE DESIGN & IMPLEMENTATION TESTING II Autumn 2011.
Testing, cont. Based on material by Michael Ernst, University of Washington.
Software Testing and Quality Assurance
Testing an individual module
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Software Systems Verification and Validation Laboratory Assignment 3
CS4311 Spring 2011 Unit Testing Dr. Guoqiang Hu Department of Computer Science UTEP.
Overview of Software Testing 07/12/2013 WISTPC 2013 Peter Clarke.
Course Outline Traditional Static Program Analysis –Theory –Classic analysis and applications Points-to analysis, CHA, RTA –The Soot analysis framework.
Testing CSE 140 University of Washington 1. Testing Programming to analyze data is powerful It’s useless if the results are not correct Correctness is.
Agenda Introduction Overview of White-box testing Basis path testing
Test Coverage CS-300 Fall 2005 Supreeth Venkataraman.
White-box Testing.
CS 217 Software Verification and Validation Week 7, Summer 2014 Instructor: Dong Si
1 Program Testing (Lecture 14) Prof. R. Mall Dept. of CSE, IIT, Kharagpur.
Reasoning about programs March CSE 403, Winter 2011, Brun.
Software Construction Lecture 19 Software Testing-2.
Testing CSE 160 University of Washington 1. Testing Programming to analyze data is powerful It’s useless (or worse!) if the results are not correct Correctness.
Theory and Practice of Software Testing
1 Test Coverage Coverage can be based on: –source code –object code –model –control flow graph –(extended) finite state machines –data flow graph –requirements.
Week 6 MondayTuesdayWednesdayThursdayFriday Testing III Reading due Group meetings Testing IVSection ZFR due ZFR demos Progress report due Readings out.
White-Box Testing Statement coverage Branch coverage Path coverage
Testing (final thoughts). equals() and hashCode() Important when using Hash-based containers class Duration { public final int min; public final int sec;
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
Week 5-6 MondayTuesdayWednesdayThursdayFriday Testing I No reading Group meetings MidtermNo Section Testing II Progress report due Readings out Testing.
Software Testing. Software Quality Assurance Overarching term Time consuming (40% to 90% of dev effort) Includes –Verification: Building the product right,
Software TestIng White box testing.
CSE373: Data Structures & Algorithms
Testing Tutorial 7.
White-Box Testing Pfleeger, S. Software Engineering Theory and Practice 2nd Edition. Prentice Hall, Ghezzi, C. et al., Fundamentals of Software Engineering.
Software Testing.
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 4 Control Flow Testing
CompSci 230 Software Construction
Testing UW CSE 160 Winter 2017.
Reasoning About Code.
Structural testing, Path Testing
White-Box Testing Techniques
Types of Testing Visit to more Learning Resources.
White-Box Testing.
Testing Approaches.
White-Box Testing.
White-Box Testing Techniques II
Testing UW CSE 160 Spring 2018.
Dataflow Testing G. Rothermel.
Testing, cont., Equality and Identity
Software Testing (Lecture 11-a)
White-Box Testing Techniques II
Reasoning About Code; Hoare Logic
Testing UW CSE 160 Winter 2016.
Testing.
White-Box Testing.
Reasoning about Loops, Conclusion
Specifications, conclusion. Abstract Data Types (ADTs)
Equality, conclusion Based on material by Michael Ernst, University of Washington.
CSE 303 Concepts and Tools for Software Development
Sudipto Ghosh CS 406 Fall 99 November 16, 1999
White-Box Testing Techniques I
White-Box Testing Techniques II
Whitebox Testing.
White-Box Testing.
Whitebox Testing.
Software Testing.
Presentation transcript:

Testing, conclusion Based on material by Michael Ernst, University of Washington

Announcements HW4 Resubmit is due tomorrow, Tuesday, March 20, 2018 at 1:59:59 pm HW5 is due next Monday, March 26, 2018 at 1:59:59 pm Exam 2 is next Thursday, March 29, 2018. Practice exam will be posted this Thursday, March 22, 2018

Announcements A few notes on HW5 You may run into scalability issues with larger datasets. Common issue: graph construction Don’t call checkRep Change data structures DO NOT TEST ON THE SUBMITTY! Resolve scalability issues before you submit. We have pushed new homework into hw04 repo, you need to pull first, then commit/push Read File Paths in hw5.html very carefully Don’t include anonymous inner classes in JUnit tests! assertTrue/assertFalse, not assert in Junit tests

Last class Testing Equality White-box testing Reference equality “Value” equality with .equals Equality and inheritance equals and hashCode Spring 18 CSCI 2600, K. Kuzmin, A Milanova

Outline Equality Testing Equality and mutation Implementing equals and hashCode efficiently Equality in ADTs Testing Def-use testing Summary of Testing

White Box Testing boolean[] primeTable[CACHE_SIZE] // returns: true if x is prime, // false otherwise boolean isPrime(int x) { if (x > CACHE_SIZE) { for (int i=2; i<x/2; i++) if (x%i==0) return false; return true; } else return primeTable[x]; Spring 18 CSCI 2600, K. Kuzmin, A Milanova (example due to Michael Ernst)

White Box Testing Ensure test suite covers (covers means executes) “all of the program” We approximate ”all of the program” using coverage targets CFG nodes CFG edges CFG paths Assumption: higher coverage implies fewer remaining errors in the program Spring 18 CSCI 2600, K. Kuzmin, A Milanova

White Box Testing: Dataflow-based Testing A definition (def) of x is x at the left-hand-side E.g., x = y+z, x = x+1, x = foo(y) A use of x is when x is at the right-hand side E.g., z = x+y, x = x+y, x>y, z = foo(x) A def-use pair of x is a pair of nodes, k and n in the CFG, s.t. k is a def of x, n is a use of x, and there is a path from k to n free of definition of x k: x=… x = … n: …= x…

White Box Testing: Dataflow-based Testing Dataflow-based testing targets: write tests that cover paths between def-use pairs Intuition: If code computed a wrong value at a def of x, the more uses of this def of x we “cover”, the higher the probability we’ll expose the error If code had erroneous use of x, the more def-use pairs we “cover”, the higher the probability we’ll expose the use

A Buggy gcd // requires a,b > 0 static int gcd(int a, int b) { int x=a; int y=b; while (x != y) { if (x > y) { x = x – 2y; } else { y = y – x; } } return x; } Let’s test with gcd(15,6) and gcd(4,8). What’s the statement coverage? Branch? We have 100% statement coverage and 100% branch coverage. a = a-2b did a wrong computation. Our test cases tested def-use pairs: (def: a = a – 2b, use: b = b - a). But they didn’t cover (a = a-2b, a=a-2b), (b=b-a, a=a-2b), (b=b-a,b=b-a).

CFG for Buggy GCD 1.x=a; y=b; Def-use pairs for x: (node 1, node 2) (4,2) (1,3) (4,3) (1,4) (4,4) (1,5) (4,5) Back edge 2. x!=y False True (1,7) (4,7) 3. x>y Def-use coverage targets: cover paths “connecting” def-use pairs False True 4.x=x-2y; 5.y=y-x; 6. 7.res=x; “Merge” node

Def-use Coverage Targets The All-defs coverage target: for every def x, cover at least one path (free of definition of x), to at least one use x The All-uses coverage target: for every def-use pair of x, cover at least one path (free of definition of x) from the def x to the use x The All-du-paths coverage target: for every def-use pair of x, cover every path (free of definition of x) from the def x to the use x Spring 18 CSCI 2600, K. Kuzmin, A Milanova

Def-use Coverage Targets Order def-use targets by strength (implication) Coverage target A is stronger than (i.e., implies) coverage target B if a test suite that achieves 100% coverage under A, achieves 100% coverage under B All-du-paths => All-uses => All-defs Spring 18 CSCI 2600, K. Kuzmin, A Milanova

White Box Testing: Dataflow-based Testing Def-use coverage forces more targeted tests Higher probability to find errors Research has shown it leads to higher quality test suites Nevertheless, def-use coverage is rarely used in practice. Why? Difficult to find ground truth, i.e., the 100% Aliasing: x.f = A and B = y.f can be a def-use pair Spring 18 CSCI 2600, K. Kuzmin, A Milanova

White Box Testing Covering “all of the program” Just a heuristic Statement coverage Branch coverage Def-use coverage (a kind of path coverage) Path coverage Just a heuristic Even 100% all-uses coverage (one of the strongest targets) can still miss bugs High coverage increases confidence in test suite

In Practice Write test suite based on spec (using paths-in-spec, equivalence partitioning, boundary values). Write test suite before code! Write code Run test suite, fix bugs, measure coverage (typically branch) If coverage is inadequate, write more tests. Go to Step 3 Good “coverage” of paths-in-spec and boundary values typically (but not always!) yields good program coverage

Specification Tests vs. Implementation Tests Specification tests are black-box tests Based entirely on the specification If some behavior is undefined in spec, then we cannot write a test case to test this behavior Implementation tests are white-box tests Based on code Covers control-flow, different algorithmic paths Code may define behavior undefined in spec. Implementation tests must test this behavior MORE Spring 18 CSCI 2600, K. Kuzmin, A Milanova

Regression Testing Regression testing is the process of re-running test suite (e.g., after a bug fix) Whenever you find a bug Add test case with input that elicited the bug Verify that test suite fails Fix the bug Verify that test suite succeeds This ensures that we populate test suite with good tests Spring 18 CSCI 2600, K. Kuzmin, A Milanova

Testing, Summary Testing cannot prove absence of bugs Testing is extremely important. Two rules Test early and test often Be systematic Large test suite does not mean quality test suite Can miss relevant test cases Use black box and white box heuristics Write tests based on Specification (black-box heuristics) Implementation (white-box heuristics) Testing cannot prove absence of bugs But can increase confidence in program