Testing During Implementation 1 *Testing During Implementation (Schach, Chap 15)  Once Source Code Available, can test code's Execution  Worst way —

Slides:



Advertisements
Similar presentations
Software Testing Techniques
Advertisements

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.
10 Software Engineering Foundations of Computer Science ã Cengage Learning.
Software Failure: Reasons Incorrect, missing, impossible requirements * Requirement validation. Incorrect specification * Specification verification. Faulty.
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
Object-Oriented Analysis and Design Lecture 10 Implementation (from Schach, “O-O and Classical Software Engineering”)
IMSE Week 18 White Box or Structural Testing Reading:Sommerville (4th edition) ch 22 orPressman (4th edition) ch 16.
Testing an individual module
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
Outline Types of errors Component Testing Testing Strategy
1 Software Testing and Quality Assurance Lecture 5 - Software Testing Techniques.
SOFTWARE TESTING WHITE BOX TESTING 1. GLASS BOX/WHITE BOX TESTING 2.
1 Software Testing Techniques CIS 375 Bruce R. Maxim UM-Dearborn.
Chapter 13 & 14 Software Testing Strategies and Techniques
1 Functional Testing Motivation Example Basic Methods Timing: 30 minutes.
CS 325: Software Engineering March 31, 2015 Software Testing Black-Box Testing White-Box Testing Regression Testing.
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
White-box Testing Black-box Testing Extensions
CMSC 345 Fall 2000 Unit Testing. The testing process.
Prof. Mohamed Batouche Software Testing.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 20 Slide 1 Defect testing l Testing programs to establish the presence of system defects.
Chapter 13: Implementation Phase 13.3 Good Programming Practice 13.6 Module Test Case Selection 13.7 Black-Box Module-Testing Techniques 13.8 Glass-Box.
1 Testing Course notes for CEN Outline  Introduction:  terminology and philosophy  Factors that influence testing  Testing techniques.
Path Testing + Coverage Chapter 9 Assigned reading from Binder.
1 Software testing. 2 Testing Objectives Testing is a process of executing a program with the intent of finding an error. A good test case is in that.
Software Testing Testing types Testing strategy Testing principles.
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.
Test Coverage CS-300 Fall 2005 Supreeth Venkataraman.
Black-box Testing.
INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 22 Slide 1 Software Verification, Validation and Testing.
1 Phase Testing. Janice Regan, For each group of units Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine.
Berrached::CS3320::Ch131 Implementation Phase Chapter 13 Classical & Object-Oriented Software Engineering by Stephen R. Schach.
1 Program Testing (Lecture 14) Prof. R. Mall Dept. of CSE, IIT, Kharagpur.
 Test Plan  Testing strategies ◦ Unit testing ◦ Integration testing ◦ Product testing ◦ Acceptance testing  Test case selection  Testing Techniques.
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.
Theory and Practice of Software 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.
Software Quality Assurance and Testing Fazal Rehman Shamil.
SOFTWARE TESTING SOFTWARE TESTING Presented By, C.Jackulin Sugirtha-10mx15 R.Jeyaramar-10mx17K.Kanagalakshmi-10mx20J.A.Linda-10mx25P.B.Vahedha-10mx53.
Dynamic White-Box Testing What is code coverage? What are the different types of code coverage? How to derive test cases from control flows?
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
ANOOP GANGWAR 5 TH SEM SOFTWARE TESTING MASTER OF COMPUTER APPLICATION-V Sem.
Software Testing. SE, Testing, Hans van Vliet, © Nasty question  Suppose you are being asked to lead the team to test the software that controls.
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.
Functional testing, Equivalence class testing
Software Testing.
Software Testing.
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 4 Control Flow Testing
Chapter 9, Testing.
Software Engineering (CSI 321)
CompSci 230 Software Construction
Chapter 13 & 14 Software Testing Strategies and Techniques
Structural testing, Path Testing
Types of Testing Visit to more Learning Resources.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Software Testing (Lecture 11-a)
Chapter 14 Software Testing Techniques
Chapter 10 – Software Testing
Software Testing “If you can’t test it, you can’t design it”
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Software Testing.
Chapter 13 & 14 Software Testing Strategies and Techniques 1 Software Engineering: A Practitioner’s Approach, 6th edition by Roger S. Pressman.
Unit III – Chapter 3 Path Testing.
Presentation transcript:

Testing During Implementation 1 *Testing During Implementation (Schach, Chap 15)  Once Source Code Available, can test code's Execution  Worst way — Random Testing: Plug in Arbitrary Input and see what happens.  Needed — a Systematic Way of Developing Test Cases Why make a big deal about testing? Why not just release software and fix it after delivery?  F-16 autopilot inverted aircraft when crossing the equator (found in simulator) (Neumann 86)  ESA lost Ariane 5 rocket due to numerical precision in inertial reference system (Gleick 96)   64 bit floating point num for horizontal velocity converted to a 16 bit signed int. Conversion over 32,767 failed 37 seconds after liftoff ($500 Million).

Testing During Implementation 2 Two Approaches to Test Case Selection  Testing To Specifications (a.k.a Black-Box Testing aka functional testing)  Testing To Specifications (a.k.a Black-Box Testing aka functional testing) Focus: what module is supposed to do, not how it does it.  Testing To Code (aka Glass-Box Testing, logic-driven, or path-oriented testing).  Focus: how code in module is structured, not what its supposed to do   Only info used in design of test cases is the spec doc   The code itself is tested, w/o regard to specifications Events: External Conditions that set the Context of the module

Testing During Implementation 3 Role of Black/Glass Box focus in Test Case Dev  Regardless as to whether black or glass box based, need the identify the following for each test case:  Once actual test case data set determined, what next?   What is being tested. Ex: myATM.deposit();   How test data id’d Ex: User Scenario: deposit $10   The actual input data. ????????   The expected output. ????????   The actual output. ???????? Need to inspect what the software actually produces as output and compare with what was expected.

Testing During Implementation 4 *Feasibility of Testing to Specifications  Combinatorial Explosion Makes Completely Testing to Specifications Impossible  Example: Specifications For Data Processing Product Include 5 Types of Commission And 7 Types of Discount. How Many Total Test Cases are needed?  Doesn’t matter if Commission and Discount computed in two entirely separate modules—the structure is irrelevant

Testing During Implementation 5 *ICE : Feasibility of Completely Testing to Specifications  Suppose Specification Includes 20 Factors, Each of Which can Take On any of 4 Values  Determine how many test cases would be needed to completely test to specification.

Testing During Implementation 6 *What about the Feasibility of Testing to Code?  If it is desired that each Path through Module be executed at least once, Combinatorial Explosion May Result // kmax in an int between // myChar is A, or B, or C

Testing During Implementation 7 *What Does Exercising Every Path Promise?  Is it Possible to exercise Every Path w/o detecting Every Fault?  Is it Possible to exercise Every Path w/o detecting Every Fault? if ((x + y + z) / 3 == x) println ("x, y, z are equal in value"); else println ("x, y, z are not equal");

Testing During Implementation 8 *More on the Feasibility of Testing to Code  A Path can be tested only if it is present  Weaker Criteria exist besides Path coverage:  Branch Coverage: Exercise all branches of all conditional statements  Statement Coverage: Execute every statement How many paths through this code?

Testing During Implementation 9 *Equivalence Testing and Boundary Value Analysis  Equivalence testing, combined with boundary value analysis, is a black-box technique of selecting test cases  Goal: New test cases chosen to detect previously undetected faults.  An equivalence class is a set of test cases such that any one member of the class is representative of any other member of the class. Assumes that any one member of the equivalence class is as good a test case as any other member of the class. Is this a good assumption? How are test cases selected?

Testing During Implementation 10 *Equivalence Classes Example  Suppose Specifications For DBMS State that product must handle any number of Records between 1 and 16,383.  Example: if System can handle 34 Records and 14,870 Records, then probably will work fine for 8,252 Records  Basic idea: If system works for a test case in range (1..16,383), then will probably work for any other test case in range; don’t bother with nearly redundant testing.

Testing During Implementation 11 *Boundary-Value Analysis  Probability of detecting a fault increases when test case on/next to boundary of an equivalence class is selected.  Thus, when testing the database product, the following cases could be selected for the Range 1..16,383  Combining Equivalence Classes With Boundary Value Analysis Yields a (relatively) small set of Test Data with the potential of uncovering a large # of Faults. Test Case # records Equivalence class? Boundary value? 1 0 records 2 1 record 3 2 records records 5 16,382 records 6 16,383 records 7 16,384 records Equivalence class 1 (& adjacent to boundary value) Eq Class 2; Adjacent to boundary value Eq Class 2; Boundary value

Testing During Implementation 12 *Boundary Value Analysis of Output Specs ICE: In 2001, Minimum Social Security (OASDI) Deduction From any one Paycheck was $0.00, and the Maximum was $4,  Using Boundary Value Analysis, what Input Data should be used to Test the Software that Implements the above deduction?

Testing During Implementation 13 *Functional Testing  An alternative (lower-level) form of black-box testing is to base the test data on the functionality of the module.  An alternative (lower-level) form of black-box testing is to base the test data on the functionality of the module.  In functional testing, each function in module is identified; test data are devised to test each function separately.  Functional testing can be difficult:  The functions within a module may consist of lower-level functions, each of which must be tested first.  Lower-level functions may be not be independent.  What problems arise when applying functional testing to OO?

Testing During Implementation 14 Shifting to Glass-Box Testing  After black box testing:  The requirements are shown to be fulfilled for test cases considered.  The interfaces are available and working.   So... Why bother with glass-box testing? After all, the source code was tested by the black-box test cases.

Testing During Implementation 15 Glass-Box Testing  Can be oriented towards  Statement Coverage (Execute every Statement at least once)  Branch Coverage (Execute every Branch at least once)  Path Coverage (Execute every Path at least once)  The code at hand is used to determine a test suite.  Ideally, you want Test Data that Exercises all Possible Paths through your Code: However, as previously discussed, likely is not possible Can Approximate by ensuring that each Path is Visited at least once, and considering equivalence classes.

Testing During Implementation 16 *Infeasible Code  It may not be possible to test a specific statement  May have an infeasible path (“dead code”) in the module  Frequently this is evidence of a fault  Many compilers can detect unreachable code as part of the parsing process

Testing During Implementation 17 Complexity Metrics: Making Testing Manageable  Goal of Using a Software Complexity Metric:  Highlight Modules Mostly Likely To Have Faults  Quality Assurance approach to Glass-Box Testing  Would be beneficial to be able to say, “Module M1 is More “Complex” than Module M2”  Problem: what do you do when you discover an unreasonably high Complexity Value for a Module?

Testing During Implementation 18 Lines of Code as a Complexity Metric  Simplest Complexity Measure; Underlying Assumption:  There exists a Constant Probability p that Line of Code Contains Fault. Based on the idea that the past can be used to predict the future.  Example: Tester Believes Line of Code Has 2% Chance of Containing Fault. Module Under Test is 100 Lines Long, Probably Contains 2 Faults

Testing During Implementation 19 McCabe's Cyclomatic Complexity Metric  Cyclomatic Complexity Metric M (McCabe, 76)  Essentially the Number of Decisions (branches) in Module M = #edges - #nodes +2  Can be used as a Metric for predicting the # of Test Cases needed for Branch Coverage  M Value for Aegis System (Walsh,79)  276 modules in Aegis  23% of modules with M > 10 contained 53% of detected faults  Modules with M > 10 had 21% more faults per line of code

Testing During Implementation 20 ICE: Applying McCabe’s Metric 1.Use statement to graph conversions 2.Count num edges (#e), num nodes (#n) 3.Compute McCabe’s Metric M = #e-#n+2 4.M > 10 is overly complex. Consider Re- designing Module 5.M value gives the recommended number of test cases needed for branch coverage. switch a { case 1: x =3; break; case 2: if (b == 0) x=2; else x=4; break; case 3: while (c>0) process(c); break; }

Testing During Implementation 21 Is Complete Black-Box/Glass-Box Testing Feasible?  The Art of Testing (after reducing complexity via analysis of McCabe’s metric and others):  Want: A Small, Manageable Set Of Test Cases: Maximize Chances of Detecting Fault, While Minimizing Chances of Wasting Test Case  What relative (Black/Glass Box) ordering of Test Cases will highlight as Many Faults As Possible?

Testing During Implementation 22 Example: Testing a Tax Computation System #include #include int main(void) { int main(void) { int numDependents, exemption; int numDependents, exemption; float income, taxSubTotal, taxTotal; float income, taxSubTotal, taxTotal; cout"Enter yearly income: "; cout<<"Enter yearly income: "; cin income; cin >> income; // first if - check income if (income 0) { cout “Cannot have ” if (income < 0) { cout << “Cannot have ” “negative income."; return 0; << “negative income."; return 0; } cout “Give # dependents+self"; cout<< “Give # dependents+self"; cin numDependents; cin >> numDependents; // second if - check dependents if (numDependents 0) { if (numDependents <= 0) { cout“Need at least one dependant"; return 0; cout<<“Need at least one dependant"; return 0; } // third if (else-if) - compute tax subtotal if (income < 10000) taxSubTotal =.02 * income; //bracket 1 if (income < 10000) taxSubTotal =.02 * income; //bracket 1 else if (income < 50000) //bracket 2 else if (income < 50000) //bracket 2 taxSubTotal = *(income-10000); taxSubTotal = *(income-10000); else //bracket 3 else //bracket 3 taxSubTotal = *(income-50000); taxSubTotal = *(income-50000); exemption numDependents * 50; exemption = numDependents * 50; taxTotataxSubTotal - exemption; taxTotal = taxSubTotal - exemption; // last if - check negative tax if (taxTotal0) taxTotal0; if (taxTotal<0) //In case of negative tax taxTotal=0; cout income ‘ ‘ taxSubTotal; cout << income <<‘ ‘ <<taxSubTotal; cout numDependents ‘ ‘; cout << numDependents << ‘ ‘; cout exemption ‘ ‘ taxTotal; cout << exemption << ‘ ‘ <<taxTotal;}

Testing During Implementation 23 Test Case Development for Path Coverage 1st if2nd ifIf-else-ifLast ifResult 1inc < 0doesn't matter negative income error 2inc >= 0numDep <= 0doesn't matter invalid dependents error 3inc >= 0numDep > 0income < 10000taxTotal < 0.02 bracket 0 tax due tax 4inc>= 0numDep > <= income < taxTotal < 0.03 bracket 0 tax due tax There are four if statements in the code (and no loops), resulting in how many paths through the code? First Few Test Cases: Group Exercise: Determine the Remaining 4 Test Cases

Testing During Implementation 24 Test Data Sets Income Num Dependents Expected Result 1-5 Don ’ t care negative income error 200invalid dependents error (bracket.02, negative tax) (bracket.03, negative tax)  To test the above, we need eight sets of data (values for income and number of dependents), one to test each possible path.   Ranges for income are fairly evident for each case; we need only select an appropriate number of dependents for each case.   Below shows 4 test data sets corresponding to the first four test cases described above, and the expected results (TaxTotal):

Testing During Implementation 25 *ICE: The remaining Equivalence Classes if (income 0) { cout “Cannot have ” if (income < 0) { cout << “Cannot have ” “negative income."; return 0; << “negative income."; return 0; } cout “Give # dependents+self"; cout<< “Give # dependents+self"; cin numDependents; cin >> numDependents; // third if (else-if) - compute tax subtotal if (income < 10000) taxSubTotal =.02 * income; if (income < 10000) taxSubTotal =.02 * income; else if (income < 50000) taxSubTotal = *(income-10000); else taxSubTotal = *(income-50000); else if (income < 50000) taxSubTotal = *(income-10000); else taxSubTotal = *(income-50000); exemption numDependents * 50; exemption = numDependents * 50; taxTotataxSubTotal - exemption; taxTotal = taxSubTotal - exemption; // last if - check negative tax if (taxTotal0) taxTotal0; if (taxTotal<0) //In case of negative tax taxTotal=0; cout income ‘ ‘ taxSubTotal; cout << income <<‘ ‘ <<taxSubTotal; cout numDependents ‘ ‘; cout << numDependents << ‘ ‘; cout exemption ‘ ‘ taxTotal; cout << exemption << ‘ ‘ <<taxTotal;} #include #include int main(void) { int main(void) { int numDependents, exemption; int numDependents, exemption; float income, taxSubTotal, taxTotal; float income, taxSubTotal, taxTotal; cout"Enter yearly income: "; cout<<"Enter yearly income: "; cin income; cin >> income; // first if - check income // second if - check dependents if (numDependents 0) { if (numDependents <= 0) { cout“Need at least one dependant"; return 0; cout<<“Need at least one dependant"; return 0; }

Testing During Implementation 26 *ICE: Compute M value for Tax Software System #include #include int main(void) { int main(void) { int numDependents, exemption; int numDependents, exemption; float income, taxSubTotal, taxTotal; float income, taxSubTotal, taxTotal; cout"Enter yearly income: "; cout<<"Enter yearly income: "; cin income; cin >> income; // first if - check income if (income 0) { cout “Cannot have ” if (income < 0) { cout << “Cannot have ” “negative income."; return 0; << “negative income."; return 0; } cout “Give # dependents+self"; cout<< “Give # dependents+self"; cin numDependents; cin >> numDependents; // second if - check dependents if (numDependents 0) { if (numDependents <= 0) { cout“Need at least one dependant"; return 0; cout<<“Need at least one dependant"; return 0; } // third if (else-if) - compute tax subtotal if (income < 10000) taxSubTotal =.02 * income; if (income < 10000) taxSubTotal =.02 * income; else if (income < 50000) taxSubTotal = *(income-10000); else taxSubTotal = *(income-50000); else if (income < 50000) taxSubTotal = *(income-10000); else taxSubTotal = *(income-50000); exemption numDependents * 50; exemption = numDependents * 50; taxTotataxSubTotal - exemption; taxTotal = taxSubTotal - exemption; // last if - check negative tax if (taxTotal0) taxTotal0; if (taxTotal<0) //In case of negative tax taxTotal=0; cout income ‘ ‘ taxSubTotal; cout << income <<‘ ‘ <<taxSubTotal; cout numDependents ‘ ‘; cout << numDependents << ‘ ‘; cout exemption ‘ ‘ taxTotal; cout << exemption << ‘ ‘ <<taxTotal;}

Testing During Implementation 27 *Fault Distribution In Modules Is Not Uniform  [Myers]: 47% of faults in OS/370 were in only 4% of the modules  [Endres]: DOS/VS (Release 28):   512 faults in a total of 202 modules 112 of the modules had only one fault There were modules with 14, 15, 19 and 28 faults, respectively – –The latter three were the largest modules in the product, with over 3000 lines of DOS macro assembler language – –The module with 14 faults was relatively small, and very unstable. What should be done with this module?

Testing During Implementation 28 * What does the detection of a fault tell us?  What does the detection of a fault within a module tell us about the probability of the existence of additional faults in the same module?  [Myers]: When a module has too many faults =>   It is cheaper to redesign, recode module than to try to fix its faults   Does finding a fault have any bearing on whether other faults are present?

Testing During Implementation 29 Comparison: Black-Box, Glass-Box, Code Review  (Hwang, 1981): All three methods equally effective  (Basili and Selby, 1987)32 professional programmers, 42 advanced students  Professional programmers code reading detected more faults code reading had faster fault detection rate  Advanced students code reading and black-box testing equally good both outperformed glass-box testing  What Conclusions can be drawn from the above?

Testing During Implementation 30 Information to Maintain on Formal Test Cases:  What program unit was tested  How test set data was arrived at: equivalence classes, boundary values;  Type of coverage : branch coverage, etc.  Actual inputs (Include global variables, files, other state information when relevant)  Expected outputs  Actual outputs  Value in running test set is in comparing expected outputs with actual outputs!

Testing During Implementation 31 *ICE: Test Case Development switch a { case 1: x =3; case 1: x =3; break; break; case 2: if (b == 0) x=2; x=2; else else x=4; x=4; break; break; case 3: while (c>0) process(c); process(c); break; break;}  Give branch coverage test cases for the switch code (note: recall the previously computed M value)  Provide the following for each test case:  What is being tested  How test data was arrived at  Give the  Actual input data set  The expected output  The actual output (simulate by executing by hand here)