Question: Design, implement, and run PC ( Predicate Coverage ) , CC ( Clause Coverage ) and CACC ( Correlated Active Clause Coverage ) tests for
Design, implement, and run PC Predicate Coverage CC Clause Coverage and CACC Correlated Active Clause Coverage tests for the method turnHeaterOn in class Thermostat.java
points List all predicates in the method. How many have one clause, two clauses, three clauses, and more than three?
For each predicate, write the truth table and choose rows from the truth tables that satisfy PC
a points You must submit the truth tables and clearly mark which rows will be used. These are your abstract tests.
b points For each abstract test, create input values that satisfy the truth assignments and that reach the predicate.
c points Implement each test in Junit file "ThermostatTestPCjava". Include comments that state which predicate and which truth assignment row in the truth table is being implemented.
d points Run your tests.
For each predicate, write the truth table and choose rows from the truth tables that satisfy CC
a points You must submit the truth tables and clearly mark which rows will be used. These are your abstract tests.
b points For each abstract test, create input values that satisfy the truth assignments and that reach the predicate.
c points Implement each test in Junit file "ThermostatTestCCjava". Include comments that state which predicate and which truth assignment row in the truth table is being implemented.
d points Run your tests.
For each predicate, write the truth table and choose rows from the truth tables that satisfy CACC.
a points You must submit the truth tables and clearly mark which rows will be used. These are your abstract tests.
b points For each abstract test, create input values that satisfy the truth assignments and that reach the predicate.
c points Implement each test in Junit file "ThermostatTestCACC.java". Include comments that state which predicate and which truth assignment row in the truth table is being implemented.
d points Run your tests.
package thermostat;
Introduction to Software Testing
Authors: Paul Ammann & Jeff Offutt
Chapter page
See ThermostatTest.java for JUnit tests
import java.io;
import java.util.;
Programmable Thermostat
public class Thermostat
private int curTemp; current temperature reading
private int thresholdDiff; temp difference until we turn heater on
private int timeSinceLastRun; time since heater stopped
private int minLag; how long I need to wait
private boolean override; has user overridden the program
private int overTemp; overriding temperature
private int runTime; output of turnHeaterOn how long to run
private boolean heaterOn; output of turnHeaterOn whether to run
private Period period; morning, day, evening, or night
private DayType day; week day or weekend day
Decide whether to turn the heater on and for how long.
public boolean turnHeaterOn ProgrammedSettings pSet
int dTemp pSet.getSetting period day;
if curTemp dTemp thresholdDiff
override && curTemp overTemp thresholdDiff &&
timeSinceLastRun minLag
Turn on the heater
How long? Assume minute per degree Fahrenheit
int timeNeeded curTemp dTemp;
if override
timeNeeded curTemp overTemp;
setRunTime timeNeeded;
setHeaterOn true;
return true;
else
setHeaterOn false;
return false;
End turnHeaterOn
public void setCurrentTemp int temperature curTemp temperature;
public void setThresholdDiff int delta thresholdDiff delta;
public void setTimeSinceLastRun int minutes timeSinceLastRun minutes;
public void setMinLag int minutes minLag minutes;
public void setOverride boolean value override value;
public void setOverTemp int temperature overTemp temperature;
for the ProgrammedSettings
public void setDay DayType curDay day curDay;
public void setPeriod Period curPeriod period curPeriod;
outputs from turnHeaterOn need corresponding getters to activate heater
void setRunTime int minutes runTime minutes;
void setHeaterOn boolean value heaterOn value;
End Thermostat class
package thermostat;
Used with the Thermostat.java example, Chapter
import java.util.;
public class ProgrammedSettings
private Map settings
new HashMap;
Property
public ProgrammedSettings
for Period p : Period.values
HashMap m new HashMap;
settings.put p m;
for DayType d : DayType.values
mput d; Default value, C
public void setSetting Period period, DayType day, int temp
settings.get periodput day temp;
public int getSetting Period period, DayType day
return settings.get periodget day;
public String toString
package thermostat;
public enum Period
MORNING, DAY, EVENING, NIGHT
package thermostat;
public enum DayType
WEEKDAY, WEEKEND
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
