Skip to Main Content
Python Testing with pytest
book

Python Testing with pytest

by Brian Okken
February 2022
Intermediate to advanced content levelIntermediate to advanced
274 pages
6h 28m
English
Pragmatic Bookshelf
Content preview from Python Testing with pytest

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. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Testing with pytest

Python Testing with pytest

Brian Okken

Publisher Resources

ISBN: 9781680509427Errata Page