March 2015
Intermediate to advanced
236 pages
5h 26m
English
Another special case: matches() returns true when the criterion is marked as “don’t care”:
| iloveyouboss/tdd-14/test/iloveyouboss/ProfileTest.java | |
| | @Test |
| | public void matchesWhenCriterionIsDontCare() { |
| | profile.add(answerDoesNotReimburseTuition); |
| | Criterion criterion = |
| | new Criterion(answerReimbursesTuition, Weight.DontCare); |
| | |
| | assertTrue(profile.matches(criterion)); |
| | } |
Making the test pass requires adding a new conditional in the matches() method:
| iloveyouboss/tdd-14/src/iloveyouboss/Profile.java | |
| | public boolean matches(Criterion criterion) { |
| | return |
| | criterion.getWeight() == Weight.DontCare || |
| | criterion.getAnswer().match(getMatchingProfileAnswer(criterion)); |
| | } |
The new test passes, but another test breaks—the first ...
Read now
Unlock full access