Test-Driven Development
with Draven
Extreme Coffee
TDD RULZ
Coderetreat 2010
TDD RULZ
Coderetreat 2010
HOW ARE U?
Fincza András
SVP of Engineering
aka Draven
We are testers!
VS
JUnit ftw!
Classic testing
After implementation, focus on the implementation & algorithm
Classic testing
After implementation, focus on the implementation & algorithm
Test-Driven Development
Tests first, high-quality code via small and verifiable steps
Test-Driven Development
Test-Driven Development
TEST PHASE
describe(`peaceMaker()`, () => {
it(`should return Peace
when Love and Humanity are given`, () => {
let result = peaceMaker(`Love`, `Humanity`)
assert.equal(result, `Peace`)
})
});
> Test runner
peaceMaker()
✘ should return Peace
when Love and Humanity are given
Test run completed!
1 out 1 tests failed :(
Test-Driven Development
IMPLEMENTATION
PHASE
describe(`peaceMaker()`, () => {
it(`should return Peace
when Love and Humanity are given`, () => {
let result = peaceMaker(`Love`, `Humanity`)
assert.equal(result, `Peace`)
})
});
peaceMaker(a, b) => {
if (a == "Love" && b == "Humanity")
return "Peace"
}
> Test runner
peaceMaker()
✔ should return Peace
when Love and Humanity are given
Test-Driven Development
REFACTORING
PHASE
describe(`peaceMaker()`, () => {
it(`should return Peace
when Love and Humanity are given`, () => {
let result = peaceMaker(`Love`, `Humanity`)
assert.equal(result, `Peace`)
})
});
peaceMaker(componentOfPeace1, componentOfPeace2) =>
if (componentOfPeace1 == "Love" &&
componentOfPeace2 == "Humanity")
return "Peace"
}
> Test runner
peaceMaker()
✔ should return Peace
when Love and Humanity are given
Test-Driven Development
Test-Driven Development
Ensures small steps
Fast feedback
Less bugs
Great coverage & testable code
Living documentation
Design first
Trust
Test-Driven Development
Let's talk about the costs...
Steep learning curve
Slower
for the first sight
Not for everything
Learning curve
TDD, BLABLA, BLABLA, ...
That's me, Draven!
I'm small
:)
REALITY VS FAKE NEWS
TV
FAKE NEWS
No Time
:(
Make it!
TV
FAKE NEWS
Do a spike!
How to test it?
TV
FAKE NEWS
Pair up!
It's too hard
:(
TV
FAKE NEWS
I have legacy
:(
Make space!
TV
FAKE NEWS
It's UI,
untestable!
Separation of concerns
TV
FAKE NEWS
I am
MOCKIST!
Just
don't
...
TV
FAKE NEWS
Not fun!
???
TDD
"Moments to learn,
lifetime to master"
THX
Extreme Coffee - TDD 2022.04.01
By drawain
Extreme Coffee - TDD 2022.04.01
- 98