liveBook · Manning

Test-driven development

As explained in Build High Value Software Systems

A development practice in which failing tests are written before implementation and then used to guide code until the tests pass.

Test-driven development (TDD) defines what working software must do before the code exists. Write a failing test, implement enough behavior to make it pass, and let the next test pull the next piece of work into scope. This catches misunderstandings earlier than writing code first and testing whatever was built. section 4.1.2

A practical test-first loop:

  • State an observable requirement as a test and confirm it fails. section 3.2.1
  • Implement the behavior the test demands, without adding speculative branches. section 4.1.2
  • Keep unit tests quick, focused on correctness, and stable through refactoring. Tests that police internal calls or run slowly can create waste instead of preventing it. section 5.2
Listing 3.2 Failing Tests
describe('GET /orders/:id', () => {
  it('should return 200 with order details for valid ID', async () => {
    const response = await request(app).get('/orders/123');
    expect(response.status).toBe(200);
    expect(response.body).toHaveProperty('id');
  });
 
  it('should return 404 when order does not exist', async () => {
    const response = await request(app).get('/orders/nonexistent');
    expect(response.status).toBe(404);
  });
});

These API tests expect 200 with order details for an existing ID and 404 for a missing one. Both fail against a temporary handler that returns 501; neither dictates how order retrieval must be implemented. section 3.2.1

Constrain a shipping calculation

Before implementing shipping rules, assert that a 3 kg domestic package costs 5.99. That test fixes one required outcome without first inventing zones, discounts, or extra edge cases. Add further behavior when a requirement calls for it. section 5.2

AI can scaffold tests from a contract or generate code to make an existing test pass; it need not decide what correctness means. TDD gives developers executable checks, regression protection, and confidence to refactor, but developer-readable tests may not explain business value to non-technical stakeholders. Behavior-driven development addresses that different communication problem with human-readable scenarios. The useful question is not whether every change needs a ritual, but whether the test expresses the behavior worth building. section 3.2.1 section 4.1.2 section 5.2

How Build High Value Software Systems covers it

How deep it goes
Works through failing API tests and a shipping assertion, then gives unit-test quality criteria; stops short of a full implementation.
Examples
Shows a 501 API stub facing 200 and 404 tests, plus payment and domestic-shipping assertions.
What it assumes
Assumes familiarity with basic tests and API responses while defining the failing-test-first practice explicitly.
What you can do after
Practice/perform test-first development by specifying failing behavior, implementing only what it requires, and maintaining fast, refactor-stable tests.
How it connects
Connects unit testing, Lean pull, behavior-driven development, and AI-assisted code generation through tests that constrain implementation.

Also explained in

Compare how 23 books explain test-driven development →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build High Value Software Systems. The section links point to the parts of the book it draws on.