Detecting specific categories of defects a tester must try to uncover any defects the other software engineers might have introduced This means designing tests that explicitly try to catch a range of specific types of defects that commonly occur www.oseng.com C Lethbridge/Laganiere 2001 Chapter 10: Testing and Inspecting for High Quality
© Lethbridge/Laganière 2001 Chapter 10: Testing and Inspecting for High Quality 11 Detecting specific categories of defects A tester must try to uncover any defects the other software engineers might have introduced. • This means designing tests that explicitly try to catch a range of specific types of defects that commonly occur
10.3 Defects in Ordinary algorithms Incorrect logical conditions Defect The logical conditions that govern looping and then-else statements are wrongly formulated esting strategy -Use equivalence class and boundary testing -Consider as an input each variable used in a rule or logical condition www.oseng.com C Lethbridge/Laganiere 2001 Chapter 10: Testing and Inspecting for High Quality 12
© Lethbridge/Laganière 2001 Chapter 10: Testing and Inspecting for High Quality 12 10.3 Defects in Ordinary Algorithms Incorrect logical conditions • Defect: —The logical conditions that govern looping and ifthen-else statements are wrongly formulated. • Testing strategy: —Use equivalence class and boundary testing. —Consider as an input each variable used in a rule or logical condition
EXample of incorrect logical conditions defect What is the hard-to-find defect in the following code The landing gear must be deployed whenever the plane is within 2 minutes from landing or takeoff, or within 2000 feet from the ground. If visibility is less than 1000 feet, then the landing gear must be deployed whenever the plane is within 3 minutes from landing or lower than 2500 feet if(!landingGearDeployed & (min(now-takeoffrime, estLandTime-now))< ( visibi1ity<1000?180:120)| re1 ative1ti七ude< visibility <1000 ft ( visibi1ity<1000?2500:2000 h new LandingGearException ()i ltitude 2 mins <2000f 2-3 mins af ter or pl altitude 2000-2500 www.oseng.com C Lethbridge/Laganiere 2001 Chapter 10: Testing and Inspecting for High Quality 13
© Lethbridge/Laganière 2001 Chapter 10: Testing and Inspecting for High Quality 13 Example of incorrect logical conditions defect What is the hard-to-find defect in the following code? • The landing gear must be deployed whenever the plane is within 2 minutes from landing or takeoff, or within 2000 feet from the ground. If visibility is less than 1000 feet, then the landing gear must be deployed whenever the plane is within 3 minutes from landing or lower than 2500 feet if(!landingGearDeployed && (min(now-takeoffTime,estLandTime-now))< (visibility < 1000 ? 180 :120) || relativeAltitude < (visibility < 1000 ? 2500 :2000) ) { throw new LandingGearException(); } Ground < 2 mins 2 - 3 mins af ter or prior to takeof f altitude < 2000 f t altitude 2000 - 2500 f t v isibility < 1000 f t a b c f g i d h j e
Defects in Ordinary Algorithms Performing a calculation in the wrong part of a control construct Defect The program performs an action when it should not or does not perform an action when it should Typically caused by inappropriately excluding or including the action from a loop or a if construct · Testing strategies -Design tests that execute each loop zero times, exactly once and more than once -anything that could happen while looping is made to occur on the first an intermediate. and the last iteration www.oseng.cor C Lethbridge/Laganiere 2001 Chapter 10: Testing and Inspecting for High Quality
© Lethbridge/Laganière 2001 Chapter 10: Testing and Inspecting for High Quality 14 Defects in Ordinary Algorithms Performing a calculation in the wrong part of a control construct • Defect: —The program performs an action when it should not, or does not perform an action when it should. —Typically caused by inappropriately excluding or including the action from a loop or a if construct. • Testing strategies: —Design tests that execute each loop zero times, exactly once, and more than once. —Anything that could happen while looping is made to occur on the first, an intermediate, and the last iteration
EXample of performing a calculation in the wrong part of a control construct while(j<maximum k=someOperation (])i J++ f(k==-l)signalAnError o)i www.oseng.cor C Lethbridge/Laganiere 2001 Chapter 10: Testing and Inspecting for High Quality 15
© Lethbridge/Laganière 2001 Chapter 10: Testing and Inspecting for High Quality 15 Example of performing a calculation in the wrong part of a control construct while(j<maximum) { k=someOperation(j); j++; } if(k==-1) signalAnError();