Multiply your Testing Effectiveness with Parameterized Testing
summary
Covers how pytest parametrization turns four triangle test cases into dozens with one function and demonstrates three concrete techniques: function parameterization, fixture parameterization, and the pytest_generate_tests hook. Uses a small triangle_type example with a deliberate bug, shows generators and CSV-driven cases (collected at collection time), adds readable IDs and markers, and explains running failures and subsets with flags like --lf and -k. Examples and code live on the linked GitHub.
AI-written summary · about
chapters (28)
- 0:00Intro
- 0:30Brian Okken
- 1:19Value of Tests
- 2:18Parametrize vs Parameterize
- 2:46Something to Test
- 4:11without Parametrization
- 5:02Moving to one test (don't do this)
- 5:47Function Parametrization
- 6:43Parameters from a named list
- 7:16Parameters from a function
- 7:55Parameters from a generator
- 8:13Parameters from a file
- 9:24Run the last failing test case
- 10:20Run test cases with 60 degree angles
- 10:34Run an individual test case
- 10:51Fixture Parametrization
- 11:59Object parameters get non-helpful names
- 12:35An ids function
- 13:22Custom ids function
- 14:03pytest_generate_tests()
- 14:41metafunc
- 15:35test.param
- 16:53indirect parameter
- 17:58indirect example
- 18:38More test cases
- 19:22Review
- 19:37Combining Techniques
- 20:20Resources
related talks
21mDon't just test, my friend, test better
27mWhy I use py.test and maybe you should too
32mpytest for unittesters
33mUnit Testing with Pytest
28mEgad! How Do We Start Writing Better Tests?
20mClimbing Out of Fixture Hell, Indirectly
38mTesting for the Terrified: How to Write Tests, Conquer Guilt, and Level Up
26mProperty Based Testing the Python Way
