March 2018
Intermediate to advanced
324 pages
8h 30m
English
Once we have the necessary test environment in place, we can add the new feature.
As a library manager, I want to know all the history for a given book so that I can measure which books are more in demand than others.
We will start with a red specification:
public class BooksSpec {
@Test
public void should_search_for_any_past_state() {
Book book1 = new Book("title", "author", States.AVAILABLE);
book1.censor();
Books books = new Books();
books.add(book1);
String available =
String.valueOf(States.AVAILABLE);
assertThat(
books.filterByState(available).isEmpty(), is(false));
}
}
Run all the tests and see the last one fail.
Implement the search on all states (fragment):
public class Book { private ArrayList<Integer> status; ...Read now
Unlock full access