Practice test naming vocabulary: should_DoX_whenY pattern, Given_When_Then naming, tests as specifications, descriptive test names, and using failing test names to communicate failures.
0 / 5 completed
1 / 5
What does the 'should_DoX_whenY' test naming pattern communicate?
The 'should_DoX_whenY' pattern (e.g., should_returnNull_whenUserNotFound) expresses the test as a specification: under condition Y, the system should do X. This format makes the test's intent legible in the test runner output without having to open the test file — you can read test results like a specification document.
2 / 5
How does 'Given_When_Then' test naming differ from its use in Gherkin?
Given_When_Then can be used as a test method naming convention even without BDD tools like Cucumber. The full test name documents: the initial state (given_userIsAdmin), the action (when_deletePost), and the expected result (then_postIsDeleted). This is more verbose than should_DoX_whenY but provides maximum clarity in the test report output.
3 / 5
'The test name documents the behaviour.' What problem does poor test naming cause?
Poorly named tests like 'test1', 'testLogin', or 'shouldWork' provide no information when they fail. A well-named test like 'should_rejectLogin_whenPasswordExceedsMaxLength' tells you immediately what broke and in what context — you can often diagnose the issue from the test name alone without reading the test body.
4 / 5
'Test descriptions as specifications.' What approach does this phrase describe?
Treating tests as specifications means writing test names and docstrings that fully describe system behaviour, so the test suite reads like a requirements document. This is the core philosophy behind BDD and tools like RSpec (Ruby) which produce readable output: 'UserAuthentication: given valid credentials: should return a session token'. The test suite becomes self-documenting.
5 / 5
'The failing test name tells you exactly what broke.' Why is this quality of test names important in CI/CD?
In a fast CI/CD workflow, a developer gets a build failure notification. If the failing test is named 'should_calculateVAT_correctlyForEUCustomers', the developer immediately knows which feature broke and in what scenario. If it's named 'test47', they must open the CI logs, find the test, open the test file, and read it — wasting time. Descriptive names compress the triage cycle.