Test-Driven Development (TDD) Flashcards
7 cards from real CAD practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 7 Test-Driven Development (TDD) flashcards as text
What is the recommended scope of a single unit test in TDD?
Answer: One behavior or scenario of a single class or function
Unit tests should verify one specific behavior in isolation so failures pinpoint the exact problem.
In TDD, 'FIRST' properties of good tests stand for:
Answer: Fast, Isolated, Repeatable, Self-validating, Timely
FIRST criteria — Fast, Isolated/Independent, Repeatable, Self-validating, Timely — define qualities of effective TDD tests.
A developer writes a test, watches it fail, writes production code, and the test passes — but skips refactoring. What risk does this create?
Answer: Technical debt accumulates as code quality degrades over time
Skipping refactoring leaves code in a rough, possibly duplicated state that becomes harder to maintain with each cycle.
Which practice complements TDD by ensuring the integrated system works as expected beyond unit tests?
Answer: Acceptance Test-Driven Development (ATDD)
ATDD extends TDD to the acceptance level, using customer-facing tests (e.g., Gherkin scenarios) to drive feature development.
When applying TDD to a legacy codebase with no existing tests, the recommended first step is to:
Answer: Add characterization tests to capture current behavior before changing code
Characterization tests document existing (possibly buggy) behavior so refactoring doesn't accidentally change it.
What is 'Fake It Till You Make It' in TDD?
Answer: Returning a hard-coded value to pass a test, then generalizing later
This technique gets the test green quickly with a hard-coded result, then additional tests force a real general solution.
Which statement about TDD and documentation is accurate?
Answer: Tests written in TDD serve as living, executable documentation of behavior
Well-named TDD tests describe intended behavior in code and always stay synchronized with the actual implementation.