nerdexam
Cisco

200-901 · Question #144

What is a tenet of test-driven development?

The correct answer is C. write and run tests before writing new code. Test-driven development (TDD) is a software development methodology where tests are written before the production code they validate. The defining tenet is the Red-Green-Refactor cycle.

Software Development and Design

Question

What is a tenet of test-driven development?

Options

  • Awrite documentation for tests
  • Bwrite tests after adding new blocks of code
  • Cwrite and run tests before writing new code
  • Drun tests after writing new code

How the community answered

(30 responses)
  • A
    3% (1)
  • B
    7% (2)
  • C
    90% (27)

Why each option

Test-driven development (TDD) is a software development methodology where tests are written before the production code they validate. The defining tenet is the Red-Green-Refactor cycle.

Awrite documentation for tests

Writing documentation for tests is a documentation practice and is not a defining principle of TDD.

Bwrite tests after adding new blocks of code

Writing tests after adding code describes the traditional 'test-last' approach, which is the inverse of TDD.

Cwrite and run tests before writing new codeCorrect

In TDD, the developer first writes a test that defines desired behavior and runs it to confirm it fails (Red), then writes only enough production code to make the test pass (Green). This discipline ensures all code is testable by design and prevents over-engineering.

Drun tests after writing new code

Running tests only after writing new code does not follow the TDD cycle, which requires tests to precede and drive the code being written.

Concept tested: Test-driven development (TDD) methodology principle

Source: https://developer.ibm.com/articles/5-steps-of-test-driven-development/

Topics

#Test-Driven Development#Software Development Practices#Unit Testing

Community Discussion

No community discussion yet for this question.

Full 200-901 Practice