FREE CAD Test-Driven Development (TDD) Questions and Answers Flashcards
6 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 6 FREE CAD Test-Driven Development (TDD) Questions and Answers flashcards as text
In TDD, what is the primary purpose of the refactoring step after a test passes?
Answer: To improve code structure without changing behavior
Refactoring in TDD improves the internal structure and readability of code while keeping all existing tests passing and behavior unchanged.
Which of the following best describes the 'Arrange-Act-Assert' pattern in TDD?
Answer: A pattern where you set up preconditions, execute the action, and verify the outcome
Arrange-Act-Assert (AAA) structures each test by setting up the test data, performing the action under test, and then verifying the expected result.
What is a 'test double' in the context of TDD?
Answer: An object that stands in for a real dependency during testing
A test double is a generic term for any object that replaces a real dependency, including mocks, stubs, fakes, and spies.
Why should TDD practitioners avoid writing multiple failing tests before making any of them pass?
Answer: It makes it unclear which code change satisfies which requirement
Writing multiple failing tests at once obscures the direct link between a specific code change and the test it satisfies, undermining the tight feedback loop TDD relies on.
In TDD, what does 'triangulation' refer to?
Answer: Adding more specific test cases to drive a more general implementation
Triangulation involves writing additional test cases with different inputs to force the implementation to become more generalized rather than hard-coded.
What is the recommended approach when a TDD practitioner discovers a bug in production code?
Answer: Write a failing test that reproduces the bug before writing the fix
Writing a failing test first ensures the bug is captured as a regression test, preventing it from reoccurring after the fix is applied.