Test Driven Development Flashcards
How is the test-driven development process?
Begins with writing a test before any functional code, emphasizing a repeatable cycle of specific steps to enhance software development and design.
Why is TDD important?
It ensures the existence of tests, enhancing software quality from the start. It also prevents the skipping of the test phase and protects the testing phase from being overlooked or undervalued by management pressures.
What is the goal of TDD?
To ensure software quality.
What are some common challenges for TDD?
Encountering professionals who undervalue it and the risk of writing ineffective tests.
What are some of the advantages of Test-Driven Development?
- Ensure Code Quality
- Clarifies Requirements Before Coding
- Facilitates Team Communication
- Prevents Code Rot
- Improves Code Structure and Organization
- Safeguards Against Regression
What are the disadvantages of Test-Driven Development?
- Increased Initial Time Investment
- Challenges in Gaining Management Buy-In
- Risk of Writing Ineffective Tests
What are the three main steps of Test-Driven Development?
- A failing test
- Write just enough production code to pass the test
- Refactor the code
What is the purpose of Step 1?
STEP 1: WRITE A FAILING TEST
Forces developers to clearly define the functionality they intend to implement before writing any production code.
What is the purpose of Step 2?
STEP 2: WRITE PRODUCTION CODE TO PASS THE TEST
Only enough code is written to make the test pass (changing the test status from red to
green). This approach ensures that no untested or excess code is added, minimizing the risk of bugs.
What is the purpose of Step 3?
STEP 3: REFACTOR THE CODE
Once the test passes, the next task is to improve the written code by making it more efficient, clean, or readable.
This step enhances the code’s modularity and maintainability without compromising the functionality confirmed by the test.
What is Red, Green, Refactor?
The iterative process for TDD’s steps is termed “Red, Green, Refactor,” symbolizing the stages
of test failure, passing the test, and
code improvement, respectively.
What is RITE?
Readable, Isolated, Thorough, Explicit.
They are principles for writing effective tests.