???????????Scrumgathering??????????о?????????????????????scrum????????????????????????????????????????????????????????????ζ??????????????????????????????????Щ????????????????????????????????????????????

??????ν?????????legacy code?????????????κβ???????????????????????Щ?????????в???????????????????Щ????????????????testability??

?????????


public class Car{
private Engine engine;
public Car(){
engine = new Engine(10);
}
public boolean isMove(){
  return engine.speed()>0? true:false;
}
}


??????????class??test case????????????


public class TestCase{
private Car car;
public void testMove(){
 car = new Car();
Assert.assertEquals(true??car.isMove());
}
}


??????????????????У????????????????????Car??isMove???????????????Car???????Engine????????????????????????????????????????isMove?????е??????????????????Car????????????н???????

??????Car??????????????????


public class Car{
private Engine engine;
public Car(Engine engine??{
this.engine = engine;
}
public boolean isMove(){
return engine.speed()>0?true:false;
}
}


??????????????£?


public class TestCase{
public Car car;
public void testIsMove(){
Engine engine = new MockEngine(10);
car = new Car(engine);
Assert.assertEquals(true??car.isMove());
}
}


??????????????????????????????????????isMove???????????????????Engine????????????mock???engine??????????????Engine????????????????п?????

??????????

????????????????????????????????????????private????????в?????????????????????????????????????????????÷???????????????е?????????????????????????·?????????????????????private???????protected????????????????????б??????????ж?protected?????????????????????????????????t??????????????