Ch3-3-sourceLogic-Thermostat

Ch3-3-sourceLogic-Thermostat - Introduction to Software...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Introduction to Software Testing Chapter 3.3 Logic Coverage for Source Code Paul Ammann & Jeff Offutt htt // d / ff tt/ ft t t http://www.cs.gmu.edu/~offutt/softwaretest/ Logic Expressions from Source ± Predicates are derived from decision statements in programs ± In programs, most predicates have less than four clauses Wise programmers actively strive to keep predicates simple ± When a predicate only has one clause COC ACC ICC and CC When a predicate only has one clause, COC, ACC, ICC, and CC all collapse to predicate coverage (PC) ± Applying logic criteria to program source is hard because of reachability and controllability : Reachability : Before applying the criteria on a predicate at a particular statement, we have to get to that statement Controllability : We have to find input values that indirectly assign values to the variables in the predicate © Ammann & Offutt 2 variables in the predicates Variables in the predicates that are not inputs to the program are called internal variables ± These issues are illustrated through an example in the following slides … Introduction to Software Testing (Ch 3)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Thermostat ( pg 1 of 2 ) 1 // Jeff Offutt--October 2010 2 // Programmable Thermostat 3 import java.io.*; 4 class thermostat 5 { 6 private Heater myHeater; 7 // Decide whether to turn the heater on, and for how long. 8 public boolean turnHeaterOn ( 9 int curTemp, /* Current temperature reading */ 10 int thresholdDiff, /* Temp difference until we turn heater on */ 11 Minutes timeSinceLastRun, /* Time since heater stopped */ 12 Minutes minLag, /* How long I need to wait */ 13 Time timeOfDay, /* current time (Hours and minutes) */ Introduction to Software Testing (Ch 3) © Ammann & Offutt 3 13 Time timeOfDay, / current time (Hours and minutes) / 14 Day dayOfWeek, /* Monday, Tuesday, . .. */ 15 Settings programmedSettings [], /* User's program, by day */ 16 boolean Override, /* Has user overridden the program */ 17 int overTemp /* OverridingTemp */ 18 ) Thermostat ( pg 2 of 2 ) 19 { 20 int desiredTemp; 21 // getPeriod() translates time into Morning, Day, Evening, Night 22 desiredTemp = programmedSettings [dayOfWeek].getDesiredTemp 23
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 8

Ch3-3-sourceLogic-Thermostat - Introduction to Software...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online