PPT12: Fixing the Defect Software Testing - CEN 4072.

Slides:



Advertisements
Similar presentations
Object Oriented Analysis And Design-IT0207 iiI Semester
Advertisements

Test process essentials Riitta Viitamäki,
Lecture 8: Testing, Verification and Validation
Delta Debugging and Model Checkers for fault localization
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.
Chapter 7: Introduction to Debugging TECH Prof. Jeff Cheng.
Testing: Who 3, What 4, Why 1, When 2, How 5 Lian Yu, Peking U. Michal Young, U. Oregon.
1 Software Maintenance and Evolution CSSE 575: Session 8, Part 3 Predicting Bugs Steve Chenoweth Office Phone: (812) Cell: (937)
CS351 © 2003 Ray S. Babcock Software Testing What is it?
Debugging CPSC 315 – Programming Studio Fall 2008.
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
Applied Software Project Management 1 Introduction Dr. Mengxia Zhu Computer Science Department Southern Illinois University Carbondale.
Testing Test Plans and Regression Testing. Programs need testing! Writing a program involves more than knowing the syntax and semantics of a language.
Test Preparation Strategies
CSE 486/586 CSE 486/586 Distributed Systems PA Best Practices Steve Ko Computer Sciences and Engineering University at Buffalo.
PRAGMATIC PARANOIA Steven Hadfield & Anthony Rice.
CSC 395 – Software Engineering Lecture 34: Post-delivery Maintenance -or- What’s Worse than Being a Code Monkey?
Software Testing. Definition To test a program is to try to make it fail.
University of Palestine software engineering department Testing of Software Systems Fundamentals of testing instructor: Tasneem Darwish.
TESTING.
University of Palestine software engineering department Testing of Software Systems Fundamentals of testing instructor: Tasneem Darwish.
Applied Software Project Management Andrew Stellman & Jennifer Greenehttp:// Applied Software Project Management Chapter 1: Introduction.
Objectives Understand the basic concepts and definitions relating to testing, like error, fault, failure, test case, test suite, test harness. Explore.
CS 501: Software Engineering Fall 1999 Lecture 16 Verification and Validation.
1 Debugging and Testing Overview Defensive Programming The goal is to prevent failures Debugging The goal is to find cause of failures and fix it Testing.
Tracking The Problem  By Aaron Jackson. What’s a Problem?  A suspicious or unwanted behavior in a program  Not all problems are errors as some perceived.
ICAPRG301A Week 4Buggy Programming ICAPRG301A Apply introductory programming techniques Program Bugs US Navy Admiral Grace Hopper is often credited with.
Verification and Validation Overview References: Shach, Object Oriented and Classical Software Engineering Pressman, Software Engineering: a Practitioner’s.
General Programming Introduction to Computing Science and Programming I.
Software Testing Testing principles. Testing Testing involves operation of a system or application under controlled conditions & evaluating the results.
Coverage – “Systematic” Testing Chapter 20. Dividing the input space for failure search Testing requires selecting inputs to try on the program, but how.
Testing E001 Access to Computing: Programming. 2 Introduction This presentation is designed to show you the importance of testing, and how it is used.
Foundations of Software Testing Chapter 5: Test Selection, Minimization, and Prioritization for Regression Testing Last update: September 3, 2007 These.
Testing -- Part II. Testing The role of testing is to: w Locate errors that can then be fixed to produce a more reliable product w Design tests that systematically.
1 Sections 1.5 & 3.1 Methods of Proof / Proof Strategy.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
Introduction to Software Testing. Types of Software Testing Unit Testing Strategies – Equivalence Class Testing – Boundary Value Testing – Output Testing.
From Quality Control to Quality Assurance…and Beyond Alan Page Microsoft.
DEBUGGING. BUG A software bug is an error, flaw, failure, or fault in a computer program or system that causes it to produce an incorrect or unexpected.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
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.
Software Testing and Maintenance 1 Code Review  Introduction  How to Conduct Code Review  Practical Tips  Tool Support  Summary.
Reasoning about programs March CSE 403, Winter 2011, Brun.
BMTRY 789 Lecture 11: Debugging Readings – Chapter 10 (3 rd Ed) from “The Little SAS Book” Lab Problems – None Homework Due – None Final Project Presentations.
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.
“Isolating Failure Causes through Test Case Generation “ Jeremias Rößler Gordon Fraser Andreas Zeller Alessandro Orso Presented by John-Paul Ore.
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 Engineering 2004 Jyrki Nummenmaa 1 BACKGROUND There is no way to generally test programs exhaustively (that is, going through all execution.
Fixing the Defect CEN4072 – Software Testing. From Defect to Failure How a defect becomes a failure: 1. The programmer creates a defect 2. The defect.
Scientific Debugging. Errors in Software Errors are unexpected behaviors or outputs in programs As long as software is developed by humans, it will contain.
PRESENTER PRIYANKA GUPTA.  Testing the complete system with respect to requirements.  In System testing, the functionalities of the system are tested.
1 CEN 4072 Software Testing PPT12: Fixing the defect.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Debugging COMP T1.
1 Software Testing Strategies: Approaches, Issues, Testing Tools.
CS 5150 Software Engineering Lecture 22 Reliability 3.
Week 6 MondayTuesdayWednesdayThursdayFriday Testing III Reading due Group meetings Testing IVSection ZFR due ZFR demos Progress report due Readings out.
Foundations of Software Testing Chapter 5: Test Selection, Minimization, and Prioritization for Regression Testing Last update: September 3, 2007 These.
Week # 4 Quality Assurance Software Quality Engineering 1.
Regression Testing with its types
Testing Tutorial 7.
Testing and Debugging PPT By :Dr. R. Mall.
Software engineering – 1
Some Simple Definitions for Testing
CSCE 315 – Programming Studio, Fall 2017 Tanzir Ahmed
PPT and video are due: no later than November 16, 5:00 PM
PPT1: How failures come to be
CS240: Advanced Programming Concepts
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
An Introduction to Debugging
Test Cases, Test Suites and Test Case management systems
Presentation transcript:

PPT12: Fixing the Defect Software Testing - CEN 4072

From defect to failure Defect – An error in the program – especially one that can cause an infection and thus a failure. Also known as a bug or fault Infection – An error in the program state – especially one that can cause a failure “ If debugging is the process of removing software bugs, then programming must be the process of putting them in. ” - Edsger Dijkstra 2

From defect to failure Create Defect Infection Infection Propagates Failure A.K.A SOL This chain must be traced and located to get out of the failure state! How a defect becomes a failure 3

From defect to failure 1.Start with the infected value that defines the failure 2.Determine possible origins of the value, following dependences in the source code 3.Using observation check each single origin to determine whether its truly infected or not. Having found the earlier infection, restart at step 2 How to locate the defect? Guaranteed to isolate the infection chain, but it’s tedious. Nobody got time for that! This determines cause/anomalies but can’t detect where the defect is Combination of induction + experimentation with observation = LOCATE AND ELIMATE THAT BUG 4

Techniques for locating defects Infections: Dependences: Causes: Anomalies: Code smells: 5

Techniques for locating defects How to integrate all these techniques? First determine what technique to focus on Later illustrations will be shown using the techniques 6

Focusing on errors These techniques help focus on specific origins Assertions – Ensure data sanity over long moment in time and a wide range in space. Any failing assertion by definition signals an infection Anomalies – Aspects of the execution whose properties are correlated with failure, such as coverage or dynamic invariants Causes – Aspects of the execution that are not only correlated with failure but actually cause the failure, as experimentally proven 7

Focusing on errors These techniques help focus on finding the defect Infections – If you already know that some origin is faulty – from a failing assertion or via observation - focus on this one first and check whether the infection cause the failure Causes – If delta debugging or any other form of experimentation has highlighted some state or input as a failure cause, focus on these causes and check whether they are infected Anomalies – Of all possible origins those that are associated with anomalies are more likely to contain errors Code smells – If you have determined code smells I you program and if one of these code smells is a possible sign origin Dependences – Anything that is not in the backward slice of the infected state cannot possibly have caused the infection. Of all possible origins, check the backward slice for infections, starting with the closest statement 8

Techniques: dependences Determine the possible origins of the infect value, following dependences in the source code 9

Techniques: observation Check each single origin to determine whether it is infect or not 10

Techniques: assertion Use assertion to rule out possible infection origins – simply because assertion guarantees that the state is sane 11

Techniques: anomaly Still have a choice between two origins. Observing the one that is abnormal reveals an infection 12

Techniques: cause transition Found a cause transition – which is a statement that causes the failure. Real defect and infection chain – due to having the origin being sane and the target being infected 13

Techniques: ordering The order in which one should use the techniques starting with Infections Infections Causes Anomalies Code smells Dependences The rules constitute the “Focus on likely origins” step in the TRAFFIC strategy. Each potential origin must then be verified whether it is infect or not, and repeat the process for infected 14

Techniques: ordering Complexity challenge If a state is sane, then one does not need to consider earlier states. Focusing on the true problems creates time complexity of tracing the pesky bug faster! 15

Is the error a cause? Being on the wrong track is dangerous. Replacing its value with a non-suspicious ones and checking whether the failure no longer occurs ensures that the origin actually causes the error If a outputs 0, it is assumed that foo is infected If a changes to 1 the program still outputs 0 Then it is known that a does not cause the output 16

Is the cause an error? A loop adds up the balance for a specific account Let’s say some people did not get their saving bonus, and Steve is counting on it You have failed Steve he was account 891. Only because the symptom was fixed rather than the cause Making the symptom disappear is not an acceptable solution as it will haunt you later Unless you didn’t like Steve 17

Debugging into existence No clue why this program fails. The boundaries are off within the loop, so replacing size with size - 1. Sounds good right? I get desired outputs and that fixed the problem! Yes! This case is known as ignorant surgery Later the program will blow up and introduce a new defect with the "fix“ 18

19

Devil’s guide to debugging Find the defect by guessing. This includes: Scatter debugging statements throughout the program Try changing code until something works Don’t back up old versions of the code Don’t bother understand what the program should do Don’t waste time understanding the problem. Most problems are trivial anyway 20

Devil’s guide to debugging Use the most obvious fix. Just fix what you see: Why bother going all the way through compute()? x = compute(y); /* compute () doesn’t work for y== 17; so fix it */ if (y == 17) {x = 25.15; } 21

22

Correcting the defect The moment. You did all the steps: tracked the bug down, have complete understanding what is going on and reproduced the failure. The correction is applied Not done yet! Must take care of four problems “ Beware of bugs in the above code; I have only proved it correct, not tried it. ” - Donald Knuth 23

Correcting the defect Does the failure no longer occur? If the failure is done you are a hero If it’s not gone: Being wrong about a correction should Leave you astonished Cause self-doubt, personal reevaluation, and deep soul searching Happen rarely Bring back old code because the defect might be somewhere else 24

Correcting the defect Did the correction introduce new problems? Make sure this does not introduce new problems Have corrections peer reviewed Have a regression test to detect unwanted behavior changes Check each correction individually Introducing new problems is a certain pitfall, and temporarily fixing is not the way to go 25

Correcting the defect Was the same mistake made elsewhere? Check for other defects caused by the same mistake Other code from the same developer Code involving the same APIs Refactoring code helps preventing similar mistakes 26

Correcting the defect Did I commit the change? Be sure to commit your changes to systems The version control system The bug tracking system This will save you the hassle of making the code work after doing something very small. Knowledge of the past is power! 27

Workarounds Defect is not difficult but correcting the defect might be reasons why it might be impossible Unable to change: The program in question cannot be changed – for instance, because it is supplied by a third party and its source code is not available Risks: The correction induces huge risks – for instead because it implies large changes throughout the system Flaw: The problem is not in the code, but overall design – that is the system design must undergo a major revision 28

Workarounds Some cases might need a workaround instead of correction in order to not cause failure A workaround is Not a permanent solution Specific to the situation at hand Tends to reintroduce the failure again Always keep track of the problem! 29

Famous workarounds Spam filters: used to solve a flaw in the system. The proper solution would be to redesign the entire system. Virus scanners: used to solve a flaw of some operating systems. The proper solution would be to assign users limited rights and ask them for proper authorization before a change. Date windowing: used to the inability of many legacy systems to deal with four- digit years. The proper solution would be to adapt the legacy systems. 30

Learning from mistakes Straight forward suggestions for ensuring that problems will not resurface Improve quality assurance: problem will not be missed in the future – and can be fixed more quickly should it occur again Improve your test suite: the test suite failed to detect the problem. Extend the suite so does not happen again (automated test) Set up assertions: inserted assertions that helped tracked the infection should be kept in the code until active production code is finished 31

Learning from mistakes More Straight forward suggestions Improve the software process: If the wrong version goes out or not tested enough. Important parts were not reviewed. It’s the process. Achieve perfection by always thinking about how to improve process Improve your analysis tools: verify whether common tools could have detected the defect early. Tools like system assertions, and tools that detect code smells 32

Facts on fixes In the ECLIPSE and MOZILLA projects, about 30 to 40% of all changes are fixes Fixes are typically two to three times small than other changes Fixes are more likely to induce failures than other changes Only 4% of one-line changes introduce new errors in the code A module that is one year older than another module has 30% fewer errors Newly written code is 2.5 times as defect prone as old code 33

Sources Images: Quotes: Book: Zeller, Andreas. Why Programs Fail: A Guide to Systematic Debugging Amsterdam: Elsevier/Morgan Kaufmann, Print. Slides: Zeller, Andreas. "Fixing the Defect." Why Programs Fail: A Guide to Systematic Debugging - Andreas Zeller - Debugging Book. N.p., n.d. Web. 19 Nov