Whetstone.
Testing to the Fusion barNaming and boundaries
Module 11 · Lesson 211 min

Naming and boundaries

Two rules catch most test slop. First, the test file is named after what it tests: FlightNumberVoTests tests FlightNumberVo, not after the ticket or the feature (anti-patterns #3, #17). If someone greps for coverage of a class, the file name is how they find it. Second, test the boundaries, not just the happy path (#14): the inclusive bound that passes, the exclusive bound that fails, the empty and null inputs.

Boundary coverage (real DisruptionDelayVoTests)
[Fact] public void DelayAtBoundary0_ReturnsSuccess() =>
    DisruptionDelayVo.Create(false, 0).IsSuccess.ShouldBeTrue();

[Fact] public void DelayAtBoundary24Hours_ReturnsSuccess() =>
    DisruptionDelayVo.Create(false, 24 * 60).IsSuccess.ShouldBeTrue();

[Fact] public void DelayBelowZero_ReturnsFailure() =>
    DisruptionDelayVo.Create(false, -1).IsFailure.ShouldBeTrue();

[Fact] public void DelayAbove24Hours_ReturnsFailure() =>
    DisruptionDelayVo.Create(false, 24 * 60 + 1).IsFailure.ShouldBeTrue();
Practice

Try it yourself

Recall

The boundary set

Name the cases a reviewer expects.

A value object validates that a delay is between 0 and 1440 minutes inclusive. Which test cases does a Fusion reviewer expect beyond a single happy path?

Reveal answer

The inclusive bounds that pass (0 and 1440), the values just past each bound that fail (-1 and 1441), and the null/missing-input case. That's anti-pattern #14: cover the inclusive bound, the exclusive miss, and empty/null, not just a mid-range success.

Quiz

Name the test file

You wrote tests for a method ValidateRevertDecision. What should the file be called?

  1. ARevertDecisionTests.cs (named after the feature area)
  2. BFUS82Tests.cs (after the ticket)
  3. CValidateRevertDecisionTests.cs (after the method under test)
  4. DDecisionTests.cs (something general)
Show answer

Correct answer: C — ValidateRevertDecisionTests.cs (after the method under test)

Anti-patterns #3 and #17: the file is named after the class or method it tests, so a grep for coverage finds it. Not the feature, not the ticket, not a vague umbrella name.

Sign in to track your progress →