nerdexam
Cisco

200-901 · Question #121

What is the first development task in test-driven development?

The correct answer is B. Write a failing test case for a desired function. The TDD cycle always begins with writing a failing test case (the 'Red' phase of Red-Green-Refactor). You define what the code should do by writing a test for it before any implementation exists. Because no code exists yet, the test must fail - this confirms the test is…

Software Development and Design

Question

What is the first development task in test-driven development?

Options

  • AWrite code that implements a desired function.
  • BWrite a failing test case for a desired function.
  • CWrite a passing test case for existing code.
  • DReverse engineer the code for a desired function.

How the community answered

(56 responses)
  • A
    4% (2)
  • B
    93% (52)
  • C
    2% (1)
  • D
    2% (1)

Explanation

The TDD cycle always begins with writing a failing test case (the 'Red' phase of Red-Green-Refactor). You define what the code should do by writing a test for it before any implementation exists. Because no code exists yet, the test must fail - this confirms the test is actually testing something meaningful. Only after a failing test exists do you write implementation code (Choice A) to make it pass. Choice C describes writing a passing test for existing code, which is retroactive testing, not TDD. Choice D (reverse engineering) has no place in TDD methodology.

Topics

#Test-Driven Development (TDD)#Software Development Methodology#Unit Testing

Community Discussion

No community discussion yet for this question.

Full 200-901 Practice