liveBook · Manning

Test name

As explained in Unit Testing Principles, Practices, and Patterns

A test name is the human-readable identifier assigned to an automated test to indicate the behavior it verifies.

A test name is a human-readable identifier that states the behavior an automated test verifies. Expressive names clarify both the expected behavior and its connection to business requirements. section 3.4

Prefer short phrases in plain English over rigid MethodUnderTest_Scenario_ExpectedResult names. Rigid templates emphasize implementation details, repeat method names, and impose a cognitive tax on readers. section 3.4

Refactoring a delivery test name

Replace IsDeliveryValid_InvalidDate_ReturnsFalse with Delivery_with_a_past_date_is_invalid. The revised name communicates the domain behavior directly without explaining where a result is returned.

How Unit Testing Principles, Practices, and Patterns covers it

How deep it goes
Contrasts rigid and plain-English conventions and refactors concrete names, but stops short of a complete naming standard.
Examples
Uses calculator and delivery examples to compare rigid identifiers with plain-English behavior descriptions.
What it assumes
Assumes familiarity with unit tests and methods while emphasizing behavior readable to programmers and domain experts.
What you can do after
Apply plain-English names that reveal verified behavior without encoding unnecessary implementation details.
How it connects
Connects unit tests with observable behavior, implementation details, readability, and business requirements.

Also explained in

Compare how 2 books explain test name →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Unit Testing Principles, Practices, and Patterns. The section links point to the parts of the book it draws on.