November 2024
Intermediate to advanced
300 pages
7h 12m
English
In Test Smell: Irrelevant Details in a Test, you added a couple of needed tests to your test list. Now that you’ve whittled down your messy initial test into two sleek, clear tests, you should find it relatively easy to add a couple of new tests.
First, write a test that demonstrates how a completed search returns false for the errored() query:
| | @Test |
| | void erroredReturnsFalseWhenReadSucceeds() { |
| | var stream = streamOn(""); |
| | var search = new Search(stream, "", ""); |
| | |
| | search.execute(); |
| | |
| | assertFalse(search.errored()); |
| | } |
Then, test the case where accessing the input stream throws an exception:
Read now
Unlock full access