1.0.0 • Published 8 years ago

beginners-tdd-workshop-by-blended v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

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

  1. What are you testing?
  2. What should it do?
  3. What is the actual output?
  4. What is the expected output?
  5. 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