PMI-ACP · Question #412
What is the purpose of running a test before you develop the code?
The correct answer is B. To ensure it fails. This question describes the first step of Test-Driven Development (TDD), a core Agile and XP practice. In TDD, you write a test before writing any production code. Running the test first should confirm it FAILS - this is critical because it validates that the test is actually…
Question
What is the purpose of running a test before you develop the code?
Options
- ATo complete all test cases
- BTo ensure it fails
- CTo ensure it passes
- DTo be cross-functional
How the community answered
(45 responses)- A4% (2)
- B93% (42)
- C2% (1)
Explanation
This question describes the first step of Test-Driven Development (TDD), a core Agile and XP practice. In TDD, you write a test before writing any production code. Running the test first should confirm it FAILS - this is critical because it validates that the test is actually testing something meaningful and that the test infrastructure is working. A test that passes before the code is written is either testing the wrong thing or the functionality already exists. Only after confirming the test fails do you write the minimum code to make it pass (Red-Green-Refactor cycle).
Topics
Community Discussion
No community discussion yet for this question.