click to reveal definition
click to flip back
You know 0 of 22 cards in current set.
Ready to get certified?
Get CertifiedNeed this expertise applied inside your organization?
Explore Our ServicesFull Glossary
Foundations
- Test-Driven Development (TDD)
- Writing an automated test before the code that makes it pass, using tests to drive design and quality.
- Test-First Principle
- Specifying how you will know code works before writing it, clarifying intent and design.
- Benefits of TDD
- Well-tested, well-designed code, fast feedback, and confidence to change code safely.
- Quality Built In
- TDD creates quality as code is written rather than inspecting it afterward.
The Cycle
- Red-Green-Refactor
- Write a failing test, make it pass simply, then improve the design.
- Red
- A small failing test specifying the next desired behavior.
- Green
- The simplest code that makes the test pass.
- Refactor
- Improving structure without changing behavior, with tests ensuring safety.
- Baby Steps
- Working in tiny increments for fast feedback and easy error detection.
Unit Testing
- Unit Test
- An automated test verifying a small unit of code in isolation.
- Arrange-Act-Assert
- A structure for tests: set up, act, then assert the expected result.
- Good Test Qualities
- Tests should be fast, isolated, repeatable, self-validating, and timely (FIRST).
- One Assert per Concept
- Keeping tests focused so failures clearly indicate what broke.
- Test Naming
- Naming tests to describe the behavior they verify, aiding readability.
Test Doubles
- Test Doubles
- Stand-ins for real dependencies used to test code in isolation.
- Stub
- A double that returns canned responses to calls made during a test.
- Mock
- A double that verifies expected interactions occurred.
- Fake
- A working but simplified implementation used for testing.
Design
- Emergent Design
- Letting design evolve through refactoring as tests drive out behavior.
- Testable Design
- Structuring code with clear responsibilities and dependencies so it is easy to test.
- Refactoring
- Improving code structure safely because passing tests catch regressions.
Applying It
- TDD Discipline
- Consistently following the cycle to gain its benefits and build the habit.