iloveyouboss_09/test/iloveyouboss/ProfileTest.java
@Test
public void matchAnswersTrueForAnyDontCareCriteria() {
Profile profile = new Profile("Bull Hockey, Inc.");
Question question = new BooleanQuestion(1, "Got milk?");
Answer profileAnswer = new Answer(question, Bool.FALSE);
profile.add(profileAnswer);
Criteria criteria = new Criteria();
Answer criteriaAnswer = new Answer(question, Bool.TRUE);
Criterion criterion = new Criterion(criteriaAnswer,
Weight.DontCare);
criteria.add(criterion);
boolean matches = profile.matches(criteria);
assertTrue(matches);
}
두 번째 테스트는 matchAnswersFalseWhenMustMatchCriteriaNotMet 메서드와 상당히 유사합니다. 사실 강조된 2줄을 제외하면 동일합니다. 아마도 테스트마다 공통된 코드를 제거할 수 있다면 잠재적인 코드 150줄2도 제거할 수 있을 것입니다. 리팩토링해 봅시다.