Sample questions
Sd Code Quality Test CodeDifficulty 1
In the DRY vs DAMP debate for test code, what does DAMP stand for?
- aDon't Assert More than Planned
- bData And Mock Pattern
- cDescriptive And Meaningful Phrases✓
- dDuplicate All Mocked Paths
Explanation:DAMP stands for Descriptive And Meaningful Phrases. It argues that test code should favor clarity and self-containment over strict deduplication, even if that means some repetition.
Sd Code Quality Test CodeDifficulty 1
Why do many testing experts argue that strict DRY (Don't Repeat Yourself) can hurt test code more than production code?
- aBecause DRY only applies to compiled languages and most test frameworks are interpreted
- bExtracting shared setup can hide the exact conditions of a failing test.✓
- cBecause test runners execute duplicated code slower than deduplicated code
- dBecause DRY requires test files to be merged into a single file per project
Explanation:When common setup or logic is extracted into shared helpers, a reader debugging a failing test often has to jump across multiple files to reconstruct what the test actually does, which harms the test's role as clear, standalone documentation.
Sd Code Quality Test CodeDifficulty 1
What is the "Mystery Guest" test smell?
- aA test that depends on external data not visible in the test itself.✓
- bA test that randomly fails on CI but passes locally without any code change
- cA test written by a developer who no longer works on the team, with no documentation
- dA test that mocks a dependency it doesn't actually use
Explanation:Mystery Guest occurs when a test relies on data or state defined outside the test body (e.g., in an external fixture file or a database seed), so the reader cannot tell what's being tested just by reading the test.
Sd Code Quality Test CodeDifficulty 1
What is the "Eager Test" smell?
- aA test that runs before its dependencies are ready, causing intermittent failures
- bA test that is executed too frequently in the CI pipeline, slowing down builds
- cA test that has no assertions at all
- dA single test method that verifies several unrelated behaviors at once.✓
Explanation:Eager Test packs multiple, loosely related checks into one test method. When it fails, the reader has to dig through several assertions to figure out which specific behavior broke.
Sd Code Quality Test CodeDifficulty 2
What is "Assertion Roulette"?
- aRandomizing the order in which assertions run to catch order-dependent bugs
- bA test with many assertions but no messages or context distinguishing them.✓
- cA testing strategy where different team members are assigned assertions at random
- dA framework feature that automatically retries failed assertions a random number of times
Explanation:Assertion Roulette describes a test containing several assertions with no descriptive failure messages. A failure report just says "assertion failed at line X" without context, forcing the reader to guess or debug to find the real cause.
Sd Code Quality Test CodeDifficulty 1
What does "line coverage" measure?
- aThe percentage of executable lines run at least once by the test suite.✓
- bThe percentage of test cases that passed successfully
- cThe percentage of all possible branch combinations that were exercised
- dThe number of lines of test code compared to the number of lines of production code
Explanation:Line coverage counts how many executable lines of production code were executed at least once during the test run, expressed as a percentage of all executable lines.