Write tests before the code
- full code coverage
- KISS
- modularity / architecture
- document
- easy to refactor
- ease collaboration (no fear to break something)
- less dependencies / useless code
- less bug fix...
- clear interfaces
But, on the other hand
- you have to maintain your tests
- some tests are hard to write: mocks, strong integration...
- difficult with legacy code
- don't push the tests to far... as everything, consume with moderation
for (const spec in specs) {
1. RED: Create a test and check it fails
2. GREEN: Code the spec so test is successfull
3. REFACTO: Refactor if needed
}
- Print a A diamond
- Print a B diamond
- Print a C diamond
- Print a D diamond
printDiamond("D") should produce a string containing
A
B B
C C
D D
C C
B B
A