March 2015
Intermediate to advanced
236 pages
5h 26m
English
The bulk of the “interesting” logic in matches() resides in the body of the for loop. Let’s write a simple test that covers one path through the loop.
Two points that glancing at the code should make obvious: we need a Profile instance, and we need a Criteria object to pass as an argument to matches().
By analyzing the code in matches() and looking at the constructors for Criteria, Criterion, and Question, we figure out how to piece together a useful Criteria object.
The analysis lets you write this part of the arrange portion of the test:
| iloveyouboss/6/test/iloveyouboss/ProfileTest.java | |
| | @Test |
| | public void test() { |
| | Profile profile = new Profile("Bull Hockey, Inc."); |
| | Question question = new BooleanQuestion(1, ... |
Read now
Unlock full access