Creating Test Cases
As with determining the goals and scope of your test strategy, generating test cases is also easier if you take a methodical approach. For generating an initial set of test cases, these criteria will be helpful:
- Start with a non-trivial, “happy path” test case.
-
Then look at test cases that represent
- interesting sets of input,
- interesting starting states,
- interesting end states, or
- all possible error states.
Some of these test cases will overlap. If a test case satisfies more than one of the above criteria, that’s fine. Let’s go through a few of the Cards features to get the hang of it.
For count, a happy path test case might be, “For an empty database, count returns 0.” However, I’d also consider this a trivial example. ...
Get Python Testing with pytest 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.