Affiliate disclosure

Book titles on this page link to Amazon. As an Amazon Associate, DataField.Dev earns from qualifying purchases — at no additional cost to you.

Further Reading: Testing and Debugging

pytest Documentation and Tutorials

  • pytest official documentation — docs.pytest.org (Tier 1) The definitive reference for pytest. Includes tutorials, how-to guides for fixtures, parametrize, markers, plugins, and advanced configuration. Start with "Get Started" if you want a walkthrough; jump to "How-to guides" when you need something specific.

  • Okken, B. (2022). Python Testing with pytest, 2nd Edition. Pragmatic Bookshelf. (Tier 1) The best dedicated book on pytest. Covers everything from basic tests through fixtures, parametrize, plugins, and CI integration. Written for developers who already know Python basics — which is exactly where you are now.

Test-Driven Development

  • Beck, K. (2003). Test-Driven Development: By Example. Addison-Wesley. (Tier 1) The original TDD book by the person who popularized the technique. Uses Java and Python examples. The first part walks through a complete TDD project step by step — it's a masterclass in the Red-Green-Refactor rhythm. Still the best introduction to the TDD mindset decades after publication.

  • Percival, H. (2017). Test-Driven Development with Python, 2nd Edition. O'Reilly. Available free online at obeythetestinggoat.com. (Tier 1) A full-length TDD tutorial using Python and Django (a web framework). Goes well beyond this chapter into web testing, but the first few chapters are excellent for understanding TDD with Python specifically. The online version is free and regularly updated.

Debugging

Software Testing Philosophy

  • Winters, T., Manshreck, T., & Wright, H. (2020). Software Engineering at Google: Lessons Learned from Programming Over Time. O'Reilly. (Tier 1) Chapters 11-14 cover Google's approach to testing at massive scale. The chapter on "Testing Overview" is particularly relevant — it discusses the testing pyramid, test size classification, and when tests provide value. Available free online.

  • Fowler, M. "TestPyramid." martinfowler.com. (Tier 2) A concise article explaining the testing pyramid (many unit tests, fewer integration tests, few E2E tests) and why this distribution works. Good companion to Section 13.2.

Code Coverage

  • pytest-cov documentation — pytest-cov.readthedocs.io (Tier 1) Documentation for the pytest coverage plugin. Shows how to generate HTML coverage reports, configure coverage thresholds, and integrate coverage into CI pipelines.

  • Fowler, M. "TestCoverage." martinfowler.com. (Tier 2) A short, influential article arguing that coverage is a useful diagnostic tool but a terrible goal. Reinforces the point from Section 13.10 that 100% coverage doesn't mean 100% correctness.

For the Curious

  • Hypothesis library — hypothesis.readthedocs.io (Tier 1) A property-based testing library for Python. Instead of writing specific test cases, you describe properties that should hold for any input, and Hypothesis automatically generates hundreds of random test cases. A fascinating next step after you've mastered traditional unit testing.

  • mutation testing (mutmut) — Search for "mutmut Python mutation testing" (Tier 2) Mutation testing works by introducing small changes (mutations) into your code and checking whether your tests catch them. If a mutation doesn't cause any test to fail, your tests have a gap. It's a way to test your tests.