Learn the vocabulary of the TDD cycle: red, green, refactor, test-first design.
0 / 10 completed
1 / 10
What does the 'red' phase mean in TDD?
In TDD, 'red' means writing a test that fails — because the production code needed to satisfy the test does not yet exist. Red indicates the test is correctly capturing an unimplemented behaviour.
2 / 10
What does the 'green' phase mean in TDD?
In TDD, 'green' means making the failing test pass — with the minimum code necessary. The goal is not elegance at this stage; it is passing the test.
3 / 10
What does 'test-first design' mean?
Test-first design (a core TDD principle) means writing a test for a specific, small unit of desired behaviour before writing the production code that satisfies it.
4 / 10
What does the 'refactor' phase in TDD involve?
Refactoring (while keeping tests green) improves code design — removing duplication, improving naming, extracting methods — without changing external behaviour. Tests provide the safety net.
5 / 10
What does 'YAGNI' mean in TDD/XP context?
YAGNI ('You Aren't Gonna Need It') is an Extreme Programming principle closely associated with TDD: only write code to satisfy a current test, not for anticipated future requirements.
6 / 10
Reviewer: 'This PR needs more green tests. The current implementation doesn't cover edge cases around negative user IDs.' What does this comment primarily indicate about the code's state during the TDD cycle?
This comment highlights that the code is 'green' – it passes the *current* tests. However, TDD isn't just about passing tests; it's about anticipating future scenarios and writing tests for those. The reviewer is pointing out a lack of coverage concerning negative user IDs, signaling a need for more robust testing.
7 / 10
Slack Message (from @Alice): 'Just wrote a test to ensure the API endpoint returns a 200 status code when the input data is valid. Now I need to add more tests to cover error conditions.' What's Alice primarily focusing on in this message, relating to TDD?
Alice is demonstrating the core principle of TDD – starting with the simplest possible test (valid input) and building from there. The 'green' phase focuses on verifying the initial functionality before adding complexity through further tests, including error handling.
8 / 10
PR Description: 'Implemented the user authentication service. Added tests for successful login and password reset requests. Further testing is needed to cover rate limiting and invalid credentials.' What does the phrase 'further testing is needed' most accurately represent within a TDD workflow?
In TDD, 'further testing' doesn't mean starting from scratch. It indicates that the current implementation is 'green' – it passes the existing tests. The next step (often called 'refactor') involves improving the code's structure and efficiency without altering its functionality, while ensuring all tests continue to pass.
9 / 10
Standup Update (from Ben): 'Yesterday, I wrote a test that verifies the function correctly calculates the discount amount based on a given percentage. Today, I'm refactoring the code to improve its readability and remove some duplicated logic.' What is Ben primarily describing in this update, relating to TDD?
Ben is explicitly referencing the 'refactor' phase. After a test passes (the function is 'green'), developers often improve the code's design, removing redundancy and enhancing readability. Crucially, this refactoring must be done *without* breaking any existing tests.
10 / 10
Code Review Comment (from Chloe): 'This code is well-tested, but it's adding a lot of complexity. We should only implement what we need now – YAGNI.' What does Chloe likely mean in this context regarding TDD?
YAGNI ('You Ain't Gonna Need It') is a core principle of XP and TDD. It encourages developers to focus on implementing only what's strictly necessary *at the time*, preventing over-engineering and unnecessary complexity. The goal is to keep the 'green' tests focused on the current requirement.
What will I learn from the "TDD Red-Green-Refactor — Vocabulary and Language" exercise?
Learn the vocabulary of the TDD cycle: red, green, refactor, test-first design.
Is this exercise free to use?
Yes. Every exercise on CoderSlingo, including this one, is free to use with no account, sign-up, or paywall required.
How many questions are in this exercise?
This set contains 10 multiple-choice questions, each with a detailed explanation shown after you answer.
Do I need to create an account to track my progress?
No account is required. Your progress bar and score reset each time you reload the page, but you can retry the exercise as many times as you like.
Who is this TDD/BDD Language exercise for?
This exercise is built for IT professionals and non-native English speakers who need to read, write, and discuss tdd/bdd language topics confidently at work.
What happens if I answer a question incorrectly?
You will see the correct answer highlighted along with a detailed explanation of why it is correct -- so every wrong answer becomes a learning moment, not just a lost point.
Can I retry this exercise?
Yes -- click "Try again" on the results screen at any time to reset your score and go through all the questions again.
How long does this exercise take to complete?
Most learners finish all 10 questions in under 10 minutes, since each question is answered by clicking a single option.
Where can I find more TDD/BDD Language exercises?
See the full TDD/BDD Language exercises hub for more vocabulary drills on this topic.
Is this exercise mobile-friendly?
Yes -- the exercise works on any device with a modern browser, including phones and tablets, with no app download required.