1.0.0 • Published 8 years ago
beginners-tdd-workshop-by-blended v1.0.0
If the code deserves to be written, it deserves to have tests.
Introduction
Why?
Before you implement, write the test.
The evidence says:
- TDD can reduce bug density.
- TDD can encourage more modular designs (enhancing software agility/team velocity).
- TDD can reduce code complexity.
5 Questions Every Unit Test Must Answer
- What are you testing?
- What should it do?
- What is the actual output?
- What is the expected output?
- How can the test be reproduced?
import test from 'tape';
// For each unit test you write,
// answer these questions:
test('What component aspect are you testing?', assert => {
const actual = 'What is the actual output?';
const expected = 'What is the expected output?';
assert.equal(actual, expected,
'What should the feature do?');
assert.end();
});
For some philosophy, see docs/TheWayOfTestivus.pdf
Sources
1.0.0
8 years ago