Summary
This chapter has shown you how to build a custom matcher to simplify your test expectations. It also discussed the importance of test-driving matcher code.
Your unit test files act as a specification of your software. It’s imperative that these files are clear and concise so that the specifications are clear. Sometimes, writing custom matchers can help you achieve that clarity.
Why do we test-drive matcher implementations? Because almost all matchers have branching logic – sometimes they’ll pass and sometimes they’ll fail – and you want to be sure that the right branches are used at the right times.
In the next chapter, we’ll switch back to refactoring our application code, with the intention of improving its testability.