Set Up Tests for Kittenbook
There’s something about the testSum
example that I really don’t like. I think the unit tests are good, and I think the example does a good job of demonstrating what types of components to include in a unit test. The problem is that testSum
does a great job of teaching the basics of unit testing, but it doesn’t show you how to test real code. Unit tests for a sum
function might not be hard to write, but how would you write tests for a real program such as kittenbook?
The first step is to think about the kittenbook code in units. The entire kittenbook project is a lot more complex than sum
, but each unit (function) can be just as simple. In fact, this is one of the big advantages of writing unit tests: For code to be ...
Get Learning to Program now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.