Automation Testing BDD and TDD in Test Automation 1 — Questions and Answers
Question 1: What does TDD stand for in software testing?
- Test-Driven Development (Correct answer)
- Test-Defined Design
- Technical Deployment Diagram
- Test Data Dictionary
Correct answer: Test-Driven Development
TDD stands for Test-Driven Development, a practice where tests are written before the actual production code is implemented.
Question 2: What is the correct order of the TDD development cycle?
- Red → Green → Refactor (Correct answer)
- Green → Red → Refactor
- Refactor → Red → Green
- Green → Refactor → Red
Correct answer: Red → Green → Refactor
TDD follows Red (write a failing test) → Green (write minimal code to pass) → Refactor (clean up code) in that exact order.
Question 3: In BDD, which tool is most commonly used for writing feature files with Gherkin syntax in Java projects?
- Cucumber (Correct answer)
- Selenium
- TestNG
- JUnit
Correct answer: Cucumber
Cucumber is the most widely used BDD tool that parses Gherkin-syntax feature files and maps their steps to executable Java step definitions.
Question 4: Which Gherkin keyword is used to define a specific individual test scenario in a feature file?
- Scenario (Correct answer)
- Feature
- Background
- Examples
Correct answer: Scenario
'Scenario' is the Gherkin keyword used to describe and introduce a specific test case within a feature file.
Question 5: What is the primary difference between TDD and BDD?
- BDD focuses on behavior from the user's perspective while TDD focuses on unit-level technical correctness (Correct answer)
- TDD uses Gherkin syntax while BDD uses code-based tests
- BDD is only for UI testing while TDD is for backend testing only
- TDD requires no test frameworks while BDD requires multiple specialized tools
Correct answer: BDD focuses on behavior from the user's perspective while TDD focuses on unit-level technical correctness
BDD extends TDD by expressing tests in natural language from the user's behavioral perspective, while TDD focuses on low-level unit correctness written by developers.
Question 6: In TDD, what should a developer do immediately after writing a test that fails (the red phase)?
- Write the minimum code necessary to make the test pass (Correct answer)
- Delete the failing test and rewrite it differently
- Add more tests before fixing the current failure
- Refactor the existing codebase first
Correct answer: Write the minimum code necessary to make the test pass
After a test fails, the developer writes only the minimal production code needed to make that specific test pass, moving to the green phase.
Question 7: Which of the following is NOT a standard Gherkin keyword used in BDD feature files?
- Execute (Correct answer)
- Given
- When
- Then
Correct answer: Execute
'Execute' is not a Gherkin keyword; standard keywords include Given, When, Then, And, But, Feature, Scenario, and Background.
What does TDD stand for in software testing?