| rule_id | 1600 |
|---|---|
| rule_category | testability |
| title | Use short concise functional test names |
| severity | 2 |
A test name should describe the behavior being verified in plain language, not the implementation detail being exercised. It should read like a sentence that a non-developer can understand, preferably in the present tense. In other words, without words like "should" and "would".
// Avoid
[Fact]
public void TestCalculations1() { ... }
[Fact]
public void CalculateTotal_WhenDiscountIsApplied_ShouldReturnReducedAmount() { ... }
// Prefer
[Fact]
public void Total_is_reduced_when_a_discount_is_applied() { ... }Use underscores to separate words if your test framework supports it. Keep names short enough to fit on one line, but long enough to communicate intent without reading the test body.