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 key difference between TDD and BDD (Behavior-Driven Development)?
Answer: BDD uses ubiquitous language and business-readable scenarios; TDD uses developer-focused unit tests
BDD builds on TDD by framing tests in domain language (Given/When/Then) readable by non-technical stakeholders.
A team is practicing TDD and finds that a new requirement makes 20 existing tests fail. The correct response is to:
Answer: Understand why they fail, update tests to reflect the new requirement, then fix production code
Failing tests signal a behavioral change; you should deliberately update tests to match the new intended behavior first.
Which tool category is commonly used to support TDD in Java projects?
Answer: Testing frameworks like JUnit combined with mocking libraries like Mockito
JUnit provides the test runner and assertions, while Mockito enables creating test doubles for dependencies.
Why should TDD tests be independent of each other?
Answer: To ensure a failure in one test does not cause cascading failures in unrelated tests
Test independence ensures each test can pass or fail on its own merits, giving precise failure signals.
In TDD, what is the significance of running the full test suite frequently?
Answer: It provides rapid feedback so defects are caught close to when they are introduced
Frequent test runs catch regressions immediately, making defects cheap to diagnose and fix.
What does 'Continuous Testing' add to a standard TDD workflow?
Answer: Tests are re-run automatically on every file save, giving near-instant feedback
Continuous testing tools watch the file system and re-execute relevant tests on save, tightening the feedback loop further.
Which statement best explains why TDD tends to produce higher-quality code than writing tests after the fact?
Answer: Writing tests first forces clear specification of behavior before implementation, catching ambiguities early
Specifying behavior upfront requires developers to think through edge cases and interfaces before getting locked into an implementation.