4 Tidying up
This chapter covers
- Writing testable examples
- Producing executable documentation
- Measuring test coverage and benchmarking
- Refactoring the URL parser
- Differences between external and internal tests
In this chapter, I'll teach you how to generate automatic and runnable documentation from code. I will show you how you can provide testable examples that never go out of date.
You'll learn about how to generate test coverage for the url package. I'll show you how to benchmark your code and give you a few tips about improving its performance.
Lastly, you'll learn to refactor the url package to make it more maintainable with the new knowledge you'll be acquiring in this chapter.
This is the last chapter of Part 1, and it's time to tidy up some left-overs from the previous chapters. Ready? Let's get started!
4.1 Testable Examples
These people again! The Wizards team, from the previous chapters. Oh my goodness. They're growing, and new people joined the team, and the existing team members got sick of explaining how the url package works to the new members. They ask you to provide sample code on using the package so the novice wizards can look at that instead of asking The Mighty Wizards.