단위테스트가 없다면 모든 변경이 잠정적인 버그다. (p.157)
public void turnOnCoolerAndBlowerIfTooHot() throws Exception{
hw.setTemp(WAY_TOO_HOT);
contoller.tic();
assertTrue(hw.heaterState());
assertTrue(hw.blowerState());
assertTrue(hw.coolerState());
assertTrue(hw.hiTempAlarm());
assertTrue(hw.loTempAlarm());
}
vs
public void turnOnCoolerAndBlowerIfTooHot(){
tooHot(); //tic 함수를 숨김
assertEquals("HBchL", hw.getState()); //켜짐:대문자, 꺼짐:소문자
}
//StringBuffer 대신 String
public String getState(){
String state = "";
state += heater ? "H" : "h";
state += blower ? "B" : "b";
state += cooler ? "C" : "c";
state += hiTempAlarm ? "H" : "h";
state += loTempAlarm ? "L" : "l";
}