CTFL 2.1.3: Recall the examples of test-first approaches to development
K1Syllabus section 2.1.3
3 original PrepBench practice questions for learning objective 2.1.3 of the CTFL 4.0 syllabus. Try the examples below and check each answer against its syllabus reference.
Practice questions
Question 1
Which approach expresses the desired behavior of an application with test cases written in a simple form of natural language, usually using the Given/When/Then format?
- Test-driven development (TDD)
- Acceptance test-driven development (ATDD)
- Behavior-driven development (BDD)
- Domain-driven design (DDD)
Show answer
- Test-driven development (TDD)TDD directs the coding through test cases rather than through natural-language behavior descriptions.
- Acceptance test-driven development (ATDD)ATDD derives tests from acceptance criteria as part of the system design process.
- Correct answer: Behavior-driven development (BDD)Natural-language test cases in Given/When/Then format characterize BDD.
- Domain-driven design (DDD)DDD is named among the development methods and Agile practices, not as a test-first approach.
Behavior-driven development expresses the desired behavior of an application with test cases written in a simple form of natural language, which is easy for stakeholders to understand, usually using the Given/When/Then format. Those test cases should then be automatically translated into executable tests.
Syllabus section 2.1.3
Question 2
Which statement characterizes test-driven development (TDD)?
- Tests are derived from acceptance criteria as part of the system design process
- The desired behavior is expressed in natural language that stakeholders understand easily
- Coding is directed through test cases, instead of through extensive software design
- Tests are written after the code, to document the behavior that was implemented
Show answer
- Tests are derived from acceptance criteria as part of the system design processDeriving tests from acceptance criteria during system design characterizes ATDD.
- The desired behavior is expressed in natural language that stakeholders understand easilyExpressing behavior in natural language for stakeholders characterizes BDD.
- Correct answer: Coding is directed through test cases, instead of through extensive software designTDD directs coding through test cases rather than extensive software design.
- Tests are written after the code, to document the behavior that was implementedWriting tests after the code would contradict the test-first basis all three approaches share.
TDD directs the coding through test cases instead of extensive software design: tests are written first, then the code is written to satisfy the tests, and then the tests and code are refactored. Like ATDD and BDD, it implements the principle of early testing and follows shift left, because the tests are defined before the code is written.
Syllabus section 2.1.3
Question 3
In which group of approaches are the tests defined before the code is written, so that they direct the development?
- TDD, ATDD and BDD
- DDD, FDD and Lean IT
- Scrum, Kanban and XP
- Waterfall, V-model and spiral
Show answer
- Correct answer: TDD, ATDD and BDDIn TDD, ATDD and BDD the tests are defined first and direct the development.
- DDD, FDD and Lean ITDDD, FDD and Lean IT are named development methods and practices, but none is characterized as test-first.
- Scrum, Kanban and XPScrum, Kanban and XP are agile practices that organize the work; they do not themselves define tests first.
- Waterfall, V-model and spiralWaterfall, V-model and spiral are SDLC models; they describe phase order, not test-first development.
TDD, ATDD and BDD are similar development approaches in which tests are defined as a means of directing development. Each implements the principle of early testing and follows shift left, since the tests are defined before the code is written. The other named items are software development methods, agile practices or SDLC models that are not characterized by defining tests first.
Syllabus section 2.1.3
Original PrepBench practice material, not official exam questions or exam dumps. PrepBench is independent and is not affiliated with or endorsed by ISTQB®.