CAD CAD Test-Driven Development and Agile Testing 1 — Questions and Answers
Question 1: In Test-Driven Development (TDD), what is the correct order of the development cycle?
- Write code, write test, refactor
- Write test, write code, refactor (Correct answer)
- Refactor, write test, write code
- Write test, refactor, write code
Correct answer: Write test, write code, refactor
TDD follows the Red-Green-Refactor cycle: write a failing test first, then write just enough code to pass it, then refactor.
Question 2: What does a 'red' phase in TDD indicate?
- The code has a runtime error
- A newly written test is failing because the feature doesn't exist yet (Correct answer)
- The build pipeline has failed
- Refactoring broke an existing test
Correct answer: A newly written test is failing because the feature doesn't exist yet
In TDD, 'red' means the test was just written and fails because the production code implementing that behavior has not yet been created.
Question 3: Which type of test validates interactions between multiple integrated components in an Agile project?
- Unit test
- Smoke test
- Integration test (Correct answer)
- Exploratory test
Correct answer: Integration test
Integration tests verify that multiple components or services work correctly together, catching interface and contract issues between units.
Question 4: What is the primary goal of Acceptance Test-Driven Development (ATDD)?
- To replace unit tests with higher-level tests
- To define acceptance criteria as executable tests before development begins (Correct answer)
- To automate regression testing after each sprint
- To measure code coverage on delivered features
Correct answer: To define acceptance criteria as executable tests before development begins
ATDD involves the whole team — developers, testers, and business stakeholders — collaboratively writing acceptance tests before coding starts to clarify requirements.
Question 5: In Agile, what is 'exploratory testing'?
- Running automated regression suites after each build
- Simultaneously designing and executing tests based on tester intuition and learning (Correct answer)
- Writing test scripts from user stories before the sprint
- Load testing the application under peak conditions
Correct answer: Simultaneously designing and executing tests based on tester intuition and learning
Exploratory testing is a simultaneous learning, test design, and execution approach where the tester adapts their strategy based on findings during the session.
Question 6: Which Agile testing quadrant focuses on technology-facing tests that support the team, such as unit and component tests?
- Quadrant 1 (Correct answer)
- Quadrant 2
- Quadrant 3
- Quadrant 4
Correct answer: Quadrant 1
Agile Testing Quadrant 1 (Q1) contains technology-facing tests that support the development team, including unit tests and component tests typically automated by developers.
In Test-Driven Development (TDD), what is the correct order of the development cycle?