My Top 10 PHPUnit Tips & Tricks
summary
Adds PHPUnit to composer, uses phpunit.xml.dist bootstrap, and insists on assertSame vs assertEquals so tests catch type issues; prefers data providers and data providers with named datasets to run every case and make failures readable. Recommends filtering tests locally, generating coverage to Clover and HTML via composer scripts, using @covers fully qualified names and optional forceCovers, and marking skips with reasons. Advises never to generate expected results from the code under test, considers mutation testing with Infection, and sometimes duplicates constants in tests to catch changes.
AI-written summary · about
chapters (16)
- 0:00Intro
- 1:09My Top 10 PHPUnit Tips & Tricks Juliette Reinders Folmer
- 2:16Have Tests
- 6:50ASSERTEQUALS ASSERTSAME
- 8:31Don't Just Test the Happy Path
- 10:05Parameter type declarations
- 10:41Limit Assertions Per Test
- 12:19Use Data Providers
- 14:03Don't Use Your Own Code To Create Test Data
- 16:09Name Your Test Cases
- 17:57Explore Filtering
- 19:32Don't Trust Code Coverage But do examine it
- 26:10Don't Leave Without Saying Goodbye
- 28:25Make Your Tests Cross-Version Compatibility
- 32:19Test Your Tests
- 34:32Lose Count
related talks
33mSo you think you know PHPUnit?
01h 03mOptimizing Your Test Suite
52mWriting Unit Tests Using PHPUnit
01h 00mPrinciples of Unit Testing
48m"PHPUnit 10-12: What to know & what to forget"
41mHow Can I Trust My Test Suite?
49mMaking PHPUnit Better
45mGetting started with test-driven development with PHPUnit
