Software Development and Project Management

Which describes how test-driven development (TDD) proceeds?

  1. AWrite a test that does not yet pass, write the minimum code to make it pass, and then refactor while keeping the tests passing
  2. BFinish writing all the code for a feature, then create test cases by following the branches in that code
  3. CDedicated testers write the tests, and developers do not run any tests until the integration testing stage
Show answer and explanation

Answer: A. Write a test that does not yet pass, write the minimum code to make it pass, and then refactor while keeping the tests passing

In test-driven development, a small piece of the specification of the feature to be built is first written as a test, which is run to confirm that it fails (red). Next, the minimum code needed to pass that test is written (green), and then duplication and other problems are cleaned up while the tests keep passing (refactor). Through this short cycle, features are added little by little while a full set of tests is maintained. In embedded firmware too, the hardware-dependent parts are made replaceable so that unit tests can be run repeatedly on a development PC.

  • A. Correct. The cycle of red (a failing test), green (the minimum code to pass) and refactor is repeated.
  • B. This is the traditional order of writing code first and tests afterwards. In test-driven development the tests are written first.
  • C. In test-driven development, developers run the tests they wrote themselves every time they write code.
Practice this topic Back to topic

Related calculators

Books on Software Development and Project Management Ad

As an Amazon Associate I earn from qualifying purchases.

More Software Development and Project Management questions

  1. Which describes continuous integration (CI)?
  2. Which correctly describes the difference between continuous delivery and continuous deployment?
  3. Which of the following requirements for a business system is a non-functional requirement?
  4. In UML, which diagram is suitable for showing how the state of an object changes in response to events (a button press, a timer expiring, a temperature being reached and so on), as in the control software of a rice cooker?
  5. In UML, which diagram shows the messages (calls and replies) exchanged between several objects in time order from top to bottom?