07 · Testing: proving it works
Article lesson
30m
1 min read
75% coverage is the law, but coverage is not the point — assertions are. Write a test that would actually catch a bug.
Tests build their own world
Test methods see no org data. Build every record you need inside the test — it is more work and it is also why your tests still pass in a fresh sandbox.
Assert like you mean it
A test without assertions is a coverage donation. Assert the field values you changed, the errors you expected, and the records you did not touch.
Practice in your org
- Open your Developer Edition org and follow along step by step
- Change one thing at a time and note what happens
- When something breaks, read the error before searching for it