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.
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)- A3% (1)
- B7% (2)
- C90% (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.
Writing documentation for tests is a documentation practice and is not a defining principle of TDD.
Writing tests after adding code describes the traditional 'test-last' approach, which is the inverse of TDD.
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.
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
Community Discussion
No community discussion yet for this question.