Expanding the Interface
We’re now ready to open up our interface and support passing a Criteria object to matches(). The next test sets the stage for creating that interface:
iloveyouboss/tdd-11/test/iloveyouboss/ProfileTest.java | |
| @Test |
| public void doesNotMatchWhenNoneOfMultipleCriteriaMatch() { |
| profile.add(answerDoesNotReimburseTuition); |
| Criteria criteria = new Criteria(); |
| criteria.add(new Criterion(answerThereIsRelo, Weight.Important)); |
| criteria.add(new Criterion(answerReimbursesTuition, Weight.Important)); |
| |
| boolean result = profile.matches(criteria); |
| |
| assertFalse(result); |
| } |
A simple hardcoded return gets the test to pass:
iloveyouboss/tdd-11/src/iloveyouboss/Profile.java | |
| public boolean matches(Criteria criteria) ... |
Get Pragmatic Unit Testing in Java 8 with JUnit now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.