Skip to content

no-bare-test-phase-comments

Test files must not use bare phase comments such as Arrange, Act, Assert, Given, When, or Then.

Why

Phase labels narrate test structure without explaining behavior and often indicate that a test needs clearer names or smaller units.

Fix

Delete the label; if the phases remain hard to follow, extract a named helper or split the test.

Examples

Before — flagged Bare Arrange, Act, and Assert labels
tests/test_widget.py
def test_widget():
# Arrange
widget = make_widget()
# Act
result = widget.run()
# Assert
assert result.ok
After — preferred Comment explains a consequence
tests/test_widget.py
def test_widget():
# A stale token here would authorize the wrong tenant.
assert request_is_rejected()

Formerly: test-phase-label-comment