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

Slides:



Advertisements
Similar presentations
Software Testing. Quality is Hard to Pin Down Concise, clear definition is elusive Not easily quantifiable Many things to many people You'll know it when.
Advertisements

Lecture 8: Testing, Verification and Validation
DETAILED DESIGN, IMPLEMENTATIONA AND TESTING Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
1 Integration Testing CS 4311 I. Burnstein. Practical Software Testing, Springer-Verlag, 2003.
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
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.
1 Software Engineering Lecture 11 Software Testing.
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
Illinois Institute of Technology
CS 425/625 Software Engineering Software Testing
SE 555 Software Requirements & Specification Requirements Validation.
Testing an individual module
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
Chapter 11: Testing The dynamic verification of the behavior of a program on a finite set of test cases, suitable selected from the usually infinite execution.
Software Testing and QA Theory and Practice (Chapter 4: Control Flow Testing) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory and Practice.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Software Testing Verification and validation planning Software inspections Software Inspection vs. Testing Automated static analysis Cleanroom software.
System/Software Testing
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
Modular Programming Chapter Value and Reference Parameters t Function declaration: void computesumave(float num1, float num2, float& sum, float&
CS 501: Software Engineering Fall 1999 Lecture 16 Verification and Validation.
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.
CS4311 Spring 2011 Unit Testing Dr. Guoqiang Hu Department of Computer Science UTEP.
Overview of Software Testing 07/12/2013 WISTPC 2013 Peter Clarke.
Lecture 11 Testing and Debugging SFDV Principles of Information Systems.
Software Reviews & testing Software Reviews & testing An Overview.
Ch6: Software Verification. 1 Decision table based testing  Applicability:  Spec. is described by a decision table.  Tables describe:  How combinations.
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.
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 22 Slide 1 Software Verification, Validation and Testing.
TESTING LEVELS Unit Testing Integration Testing System Testing Acceptance Testing.
What is Testing? Testing is the process of finding errors in the system implementation. –The intent of testing is to find problems with the system.
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
Software Engineering Issues Software Engineering Concepts System Specifications Procedural Design Object-Oriented Design System Testing.
SOFTWARE TESTING. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves any activity.
Chapter 1 Software Engineering Principles. Problem analysis Requirements elicitation Software specification High- and low-level design Implementation.
Dynamic Testing.
HNDIT23082 Lecture 09:Software Testing. Validations and Verification Validation and verification ( V & V ) is the name given to the checking and analysis.
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.
CS223: Software Engineering Lecture 21: Unit Testing Metric.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
Verification vs. Validation Verification: "Are we building the product right?" The software should conform to its specification.The software should conform.
CS223: Software Engineering Lecture 26: Software Testing.
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
Testing Integral part of the software development process.
PREPARED BY G.VIJAYA KUMAR ASST.PROFESSOR
Software Testing.
CS223: Software Engineering
Software Testing.
Rekayasa Perangkat Lunak Part-13
Software Testing.
Control Flow Testing Handouts
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 4 Control Flow Testing
Software Engineering (CSI 321)
Software Testing and Maintenance 1
Outline of the Chapter Basic Idea Outline of Control Flow Testing
Structural testing, Path Testing
Types of Testing Visit to more Learning Resources.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Software testing strategies 2
Software Testing (Lecture 11-a)
Lecture 09:Software Testing
Chapter 10 – Software Testing
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Software Reviews.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Software Testing and QA Theory and Practice (Chapter 5: Data Flow Testing) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory and Practice.
Presentation transcript:

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

Outline  Inspections and Reviews  Levels of Testing —Unit, integration, system, acceptance  Regression Testing  Input Coverage Testing: —Equivalence class testing —Alpha and beta testing  Structural Coverage Analysis  CRUD testing  Oracles  More testing techniques —Usability tests —Security tests —…

Static and Dynamic Testing  Static testing: the software is not actually executed. —Generally not detailed testing —Reviews, inspections, walkthrough  Dynamic testing: test the dynamic behavior of the software —Usually need to run the software.

Black, White and Grey Box Testing  Black box testing: assume no knowledge about the code, structure or implementation.  White box testing: fully based on knowledge of the code, structure or implementation.  Grey box testing: test with only partial knowledge of implementation. —E.g., algorithm review.

Reviews  Static analysis and dynamic analysis  Black-box testing and white-box testing  Reviews are static testing. —Formal design reviews: DR / FDR —Peer reviews: inspections and walkthrough

Formal Design Review  The only reviews that are necessary for approval of the design product.  The development team cannot continue to the next stage without this approval.  Maybe conducted at any development milestone: —Requirement, system design, unit/detailed design, test plan, code, support manual, product release, installation plan, etc.

FDR Procedure  Preparation: —find review members (5-10), —review in advance: could use the help of checklist.  A short presentation of the document.  Comments by the review team.  Verification and validation based on comments.  Decision: —Full approval: immediate continuation to the next phase. —Partial approval: immediate continuation for some part, major action items for the remainder. —Denial of approval: repeat FDR after action items.  Generate FDR report.  Follow up.

Inspections and Walkthrough  Inspection: a step-by-step peer group review of a work product, with each step checked against predetermined criteria.  Roles: —Moderator: the entire inspection procedure —Recorder: document defects found —Reviewer: everyone in the inspection team —Reader: read aloud small logical units —Producer: author of the work product.  Walkthrough: the author leads the team through a manual execution of the product using predefined scenarios.

Requirement Reviews  Participants: customers, system analysts, designers, developers, QAs.  Review leader: project manager  Objectives: —Check for accuracy and completeness of requirements and use cases. —Help designers, developers and QA understand the specifications and remove ambiguity.  Customers can start acceptance test plan once this review is complete.

System Design Reviews  Participants: system analysts, designers, developers and QAs.  Review leader: system architect?  Objectives: —Check the design against the requirements  System test plan is generally reviewed in conjunction with the system design and its requirements.

Detailed Design Reviews  Participants: designers and developers  Review leader: subsystem team leader?  Objectives: —Make sure that detailed design of modules, classes and functions is consistent with system design.  This usually includes a unit test plan and mapping of functions to requirements.

Test Plan Reviews  Participants: QAs, development team  Review leader: QA manager  Objectives: —Everyone has the same interpretation on how the product will be tested. —Quality check on the test plan. —Final check on the requirements.

Code Inspections  Participants: programmers  When: unit testing has had at least one pass.  Line by line, function by function code review against coding standards for —Efficiency —Coverage of requirements —Robustness against exceptions —Etc.  Moderator’s job: —Organize and keep them on a positive note —Do not degenerate it into arguments on what is the best way to do something.

The V Model User Requirements System Requirements Design Implementation Unit test Integration Test System Test Acceptance Test Regression Test validation verification use information of

Unit Testing  Test program units in isolation. —Errors found can be attributed to a specific unit  easy to fix. —Verify that each distinct execution of a unit produces expected result.  Often is part of the detailed design documents.  Static unit testing: code inspections/walkthroughs  Dynamic unit testing  Test driven development (discussed later)

Dynamic Unit Test Environment Unit under test Test Driver Stub Call and pass Input parameters Output parameters CallAcknowledge CallAcknowledge Results

Test Drivers and Stubs  The driver and the stubs are never discarded after the unit test because they may need to be reused for regression test. —Update the driver and stubs if the unit is updated. —Put them under CM.  Each unit should have its own test driver and stubs, Otherwise: —The driver may be too complicated —Side effects  Each driver should have its own segregated input data set.  Test drivers should automatically determine fail/pass.

Select Test Data for Unit Testing  Control flow testing  Data flow testing  Domain testing  Functional Program Testing

Control Flow Testing Draw a control flow graph from the unit under test Select a few control flow testing criteria Identify paths in the graph to satisfy the selected criteria Derive path predicate expressions from the selected paths Generate test inputs by solving the predicate expressions

Control Flow Graph (CFG): Symbols Computation Decision True False Sequential computation Decision pointMerge point

CFG: Example cin >> x >> y >> z; if ( x > 1 && y == 0 ) z = z / x; if ( z == 2 || y > 1 ) z = z + 1; return z; OR >> z

CFG: Example cin >> x >> y >> z; if ( x > 1 && y == 0 ) z = z / x; if ( z == 2 || y > 1 ) z = z + 1; return z; Better because it considers the short-circuit evaluation! >> z But for some coverage criteria, we still use the previous one!

Control Flow Coverage Criteria  Function coverage: make sure all functions in a module are executed. (easy)  Statement coverage  Decision coverage  Condition coverage  Condition/Decision coverage (C/DC)  Modified Condition/Multiple Decision coverage (MC/DC)  All-path coverage

Statement Coverage cin >> x >> y >> z; if ( x > 1 && y == 0 ) z = z / x; if ( z == 2 || y > 1 ) z = z + 1; return z; Input x y z cin >> x >> y >> z; if ( x > 1 && y == 0 ) z = z / x; if ( z == 2 || y > 1 ) z = z + 1; return z; >> z 1,2,3,4,5,6 Path predicate: (x>1&&y==0)&&(z/x==2||y>1)

>> z Decision Coverage Input x y z cin >> x >> y >> z; if ( x > 1 && y == 0 ) z = z / x; if ( z == 2 || y > 1 ) z = z + 1; return z; Each branching point has two decisions: True or False! A.K.A. Branch coverage 1,2,3,4,5,6 Path 1,2,4,6 predicates: 1: (x>1&&y==0)&&(z/x==2||y>1) 2: !(x>1&&y==0)&&!(z==2||y>1)

Decision Coverage Input x y z >> z cin >> x >> y >> z; if ( x > 1 && y == 0 ) z = z / x; if ( z == 2 || y > 1 ) z = z + 1; return z; Each branching point has two decisions: True or False! A.K.A. Branch coverage ,2,3,4,5,7,8 Path 1,2,3,5,6,8 1,2,5,6,7,8

Condition Coverage Input x y z >> z cin >> x >> y >> z; if ( x > 1 && y == 0 ) z = z / x; if ( z == 2 || y > 1 ) z = z + 1; return z; Each condition need to be tested for both True and False! A.K.A. Predicate coverage ,2,3,4,5,7,8 Path 1,2,3,5,6,8 1,2,5,6,7,8

Condition Coverage >> z cin >> x >> y >> z; if ( x > 1 && y == 0 ) z = z / x; if ( z == 2 || y > 1 ) z = z + 1; return z; Each condition need to be tested for both True and False! A.K.A. Predicate coverage Condition coverage cannot guarantee decision coverage! e.g., if ( A && B ) All leaf-level Boolean expressions are considered as conditions.

Condition/Decision Coverage  Combines the requirements of both Condition and Decision coverage. A v B 1A v B == True // true decisions 2A v B == False // false decisions 3A == True // condition 4A == False // condition 5B == True // condition 6B == False // condition Decision coverage of the second type of CFG actually guarantees the condition coverage and condition/decision coverage!

Modified Condition/Multiple Decision coverage  MC/DC enhances the Condition/Decision Coverage testing by requiring each Condition (A, B) to independently influence the Decision (True or False).  There are eight conditions that must be met to ensure MC/DC. A v B 1A v B == True // true decisions 2A v B == False // false decisions 3A == True // condition 4A == False // condition 5B == True // condition 6B == False // condition Show that each condition independently affect the decision 7There is a B value such that A v False == A v B 8There is an A value such that B v False == A v B

Modified Condition/Multiple Decision coverage  MC/DC enhances the Condition/Decision Coverage testing by requiring each Condition (A, B) to independently influence the Decision (True or False).  There are eight conditions that must be meet to ensure MC/DC. A ^ B 1A ^ B == True // true decisions 2A ^ B == False // false decisions 3A == True // condition 4A == False // condition 5B == True // condition 6B == False // condition Show that each condition independently affect the decision 7There is a B value such that A ^ True == A ^ B 8There is an A value such that B ^ True == A ^ B

MC/DC Example  Just for the “independent affect the decision”: A ^ B ^ C Test CaseABCresult 1TTTT 2TTFF 3TFTF 4TFFF 5FTTF 6FTFF 7FFTF 8FFFF

MC/DC Example  Just for the “independent affect the decision”: A ^ B ^ C Test CaseABCresult 1TTTT 2TTFF 3TFTF 4TFFF 5FTTF 6FTFF 7FFTF 8FFFF

MC/DC Example  Just for the “independent affect the decision”: A ^ B ^ C Test CaseABCresult 1TTTT 2TTFF 3TFTF 4TFFF 5FTTF 6FTFF 7FFTF 8FFFF

MC/DC Example  Just for the “independent affect the decision”: A ^ B ^ C Test CaseABCresult 1TTTT 2TTFF 3TFTF 4TFFF 5FTTF 6FTFF 7FFTF 8FFFF

MC/DC Example A ^ B ^ C Test CaseABCresult 1TTTT 2TTFF 3TFTF 5FTTF

MC/DC Exercise 1  Generate a set of test cases of the following code to satisfy MC/DC coverage: if ( A || B && C ) then do something Test CaseABCresult 1TTTT 2TTFT 3TFTT 4TFFT 5FTTT 6FTFF 7FFTF 8FFFF

MC/DC Exercise 2 Input x y z cin >> x >> y >> z; if ( x > 1 && y == 0 ) z = z / x; if ( z == 2 || y > 1 ) z = z + 1; return z; Check the 8 items in the table itemif1if >> z

MC/DC Exercise 2 Input x y z cin >> x >> y >> z; if ( x > 1 && y == 0 ) z = z / x; if ( z == 2 || y > 1 ) z = z + 1; return z; Check the 8 items in the table itemif1if NN 8YN >> z 1 0 3

All-Path Coverage  Only possible for extremely small programs.  In most cases, not feasible because of the large number of possible paths. —consider a program with a while loop. —how many possible path for the following code: if(a &&b&&c) then … if(a||b||c) then … if(a&&d||e) then …

Data Flow Testing Draw a data flow graph from the unit under test Select a few data flow testing criteria Identify paths in the graph to satisfy the selected criteria Derive path predicate expressions from the selected paths Generate test inputs by solving the predicate expressions

Data Flow Coverage Motivations  A variable is defined but never used! count  A variable is used before defined! zValue  A variable is defined twice before used! xValue int xValue, yValue, zValue; int count = 0; cin >> xValue >> yValue; xValue = 10; yValue *= xValue; if ( yValue < zValue ) yValue = zValue;

Data Flow Graph  Objective: identify data definitions and their uses.  Definition of a variable: when a value is moved into the memory location of that variable. e.g. cin >> x; i = x;  Use of a variable: when the value is fetched from the memory location of the variable. —c-use (computation use): i++; —p-use (predicate use): while ( i < 100 )  a def-clear subpath for a definition d of v and a use u of v is a subpath in the CFG between d and u on which v is not redefined

Data Flow Graph  DFG is a directed graph constructed as follows: —a sequence of definitions and c-uses is associated with each node —a set of p-uses is associated with each edge

DFG: def-c-use table Node idef(i)c-use 1{x, y, z}{} 2 3{z}{x, z} 4{} 5{z} 6{}{z} >> z

DFG: predicate-p-use table edge (i,j)predicatep-use (1,2)true{} (2,3)x>1&& y==0{x,y} (2,4)!(x>1&&y==0){x,y} (3,4)true{} (4,5)z==2||y>1{y,z} (4,6)!(z==2||y>1){y,z} (5,6)true{} >> z

DFG: labels on nodes >> z {d1(x), d1(y), d1(z)} {p2(x), p2(y)} {d3(z), c3(x), c3(z)} {p4(z), p4(y)} {d5(z), c5(z)} {c6(z)}

Rapps and Weyuker’s Data Flow Criteria  All-defs  All-p-uses  All-c-uses  All-p-uses/Some-c-uses  All-c-uses/Some-p-uses  All-uses  All-du-pairs

All-defs coverage  Some definition-clear subpath from each definition to some use reached by that definition. d1(x) d1(y) d1(z) d3(z) d5(z) 1,2 1,2,3 3,4 5,6 1,2,3,4,5,6 >> z {d1(x), d1(y), d1(z)} {p2(x), p2(y)} {d3(z), c3(x), c3(z)} {p4(z), p4(y)} {d5(z), c5(z)} {c6(z)}

All-p-uses coverage  Some definition-clear subpath for each variable from each definition to each p-use reached by that definition and each successor node of the use. d1(x)-p2(x) d1(y)-p2(y) d1(y)-p4(y) d1(z)-p4(z) d3(z)-p4(z) 1,2,3 1,2,4,5 3,4,5 1,2,3,4,6 1,2,4,6 1,2,4 1,2,4,6 3,4,6 1,2,3,4,5,6 1,2,4,5,6 >> z {d1(x), d1(y), d1(z)} {p2(x), p2(y)} {d3(z), c3(x), c3(z)} {p4(z), p4(y)} {d5(z), c5(z)} {c6(z)} 1,2,4,5 1,2,4,6

All-c-uses coverage  Some definition-clear subpath for each variable from each definition to each c-use reached by that definition. d1(x)-c3(x) d1(z)-c3(z) d1(z)-c5(z) d1(z)-c6(z) d3(z)-c5(z) d3(z)-c6(z) d5(z)-c6(z) 1,2,3 3,4,5,6 1,2,3,4,5,6 1,2,4,5,6 1,2,4,5 1,2,4,6 3,4,6 5,6 1,2,4,6 1,2,3,4,6 >> z {d1(x), d1(y), d1(z)} {p2(x), p2(y)} {d3(z), c3(x), c3(z)} {p4(z), p4(y)} {d5(z), c5(z)} {c6(z)}

Other coverage criteria  All-p-uses/Some-c-uses is identical to all-p-use except when a variable doesn’t have any p-use: —in that case, use the c-use of that variable instead.  All-c-uses/Some-p-uses is the same: when a variable doesn’t have any c-use, use its p-use instead.  All-uses: combination of all-c-uses and all-p-uses.  All-du-paths: for each definition of each variable, all def-clear paths that are cycle-free or simple-cycles to each use of the variable.

Relationship Among Coverage Criteria