liveBook · Manning

Test-driven development

As explained in Pro ASP.NET Core 7, Tenth Edition

Test-driven development is a software development practice in which tests are written before the implementation they verify.

Test-driven development (TDD) writes tests for a feature before implementing the feature. This forces the success and failure criteria into the open instead of letting difficult implementation details determine what gets tested. section 6.3.5

A practical TDD loop is:

  • Write tests that describe the feature; they fail because the feature does not exist. section 6.3.5
  • Add application code incrementally until the tests pass, moving from red to green. section 6.3.5
  • Isolate dependencies when necessary, using an interface and a fake data source to control test data. section 6.3.5

Controller feature

A controller test can supply products through a fake IDataSource rather than the production ProductDataSource, then verify the Index action's model. The same boundary makes the test independent of its real data source. section 6.3.5

How Pro ASP.NET Core 7, Tenth Edition covers it

How deep it goes
Explains the rationale and red-to-green cycle, but stops short of presenting detailed TDD variations or a complete test-first feature build.
Examples
Uses an ASP.NET Core controller, Product objects, IDataSource, and a fake data source to illustrate isolated tests.
What it assumes
Assumes familiarity with application code and unit testing while simplifying dependency management before introducing dependency injection.
What you can do after
Practice/perform test-first development with explicit success criteria and progressively broader feature coverage.
How it connects
Connects TDD with unit testing, component isolation, dependency injection, interfaces, controllers, and fake implementations.

Also explained in

Compare how 15 books explain test-driven development →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro ASP.NET Core 7, Tenth Edition. The section links point to the parts of the book it draws on.