March 2015
Intermediate to advanced
236 pages
5h 26m
English
A well-abstracted test emphasizes everything that’s important to understanding it and deemphasizes anything that’s not. The data used in a test should help tell a story.
Sometimes you’re forced to supply data to get code to compile, even though that data is irrelevant to the test at hand. For example, a method might take additional arguments that have no impact on the test.
Our test contains some “magic literals” that aren’t at all clear:
| iloveyouboss/test-3/test/util/SearchTest.java | |
| | Search search = new Search(stream, "practical joke", "1"); |
and:
| iloveyouboss/test-3/test/util/SearchTest.java | |
| | assertThat(search.getMatches(), containsMatches(new Match[] { |
| | new Match("1", "practical joke", |
| | |
Read now
Unlock full access