Test Driven Development Flashcards
1
Q
Test Driven Development (TDD)
A
TDD Circle of Life:
- Write failing test
- Make test pass with minimum code
- Refactor
- Repeat
2
Q
TDD Strategy
A
- Create a list of tests needed.
- Start by writing just enough test code
- Always run the test to see it fail in the way you expect
- Write enough code to make the test build
- Write enough code to make that test pass
a) If you can’t solve it, fake it! - When the implementation is obvious then continue, if it is not then go back to #4
- Refactor
3
Q
Refactoring
A
Refactoring introduces modifications to the code intended to improve the structure or design without changing functionality.
4
Q
Simple Ways to refactor
A
Eliminate duplicate code Extract a method by breaking down long difficult methods Extract complex operations to variables Introduce constants for magic numbers Simplify conditional expressions
5
Q
Katas
A
A code kata is an exercise in programming which helps programmers hone their skills through practice and repetition.
TDD is a common method used to solve code katas to allow first focusing on the problem and then being able to focus on the quality of the code and experimentation with new ideas.