Unit Testing
Last updated
Was this helpful?
Last updated
Was this helpful?
Source:
Design aid: Writing tests first gives you a clearer perspective on the ideal API design.
Feature documentation (for developers): Test descriptions enshrine in code every implemented feature requirement.
Test your developer understanding: Does the developer understand the problem enough to articulate in code all critical component requirements?
Quality Assurance: Manual QA is error prone. In my experience, it’s impossible for a developer to remember all features that need testing after making a change to refactor, add new features, or remove features.
Continuous Delivery Aid: Automated QA affords the opportunity to automatically prevent broken builds from being deployed to production.
The evidence says:
TDD can reduce bug density.
TDD can encourage more modular designs (enhancing software agility/team velocity).
TDD can reduce code complexity.
Says science: There is significant empirical evidence that TDD works*.
Before you implement, write the test.
Design aid: written during design phase, prior to implementation.
Feature documentation & test of developer understanding: The test should provide a clear description of the feature being tested.
QA/Continuous Delivery: The tests should halt the delivery pipeline on failure and produce a good bug report when they fail.
A failing test should read like a high-quality bug report.
What’s in a good test failure bug report?
What were you testing?
What should it do?
What was the output (actual behavior)?
What was the expected output (expected behavior)?
Equal is your new default assertion. It is the staple of every good test suite.
What are you testing?
What should it do?
What is the actual output?
What is the expected output?
How can the test be reproduced?
|