Upload
marcelo-cure
View
316
Download
1
Embed Size (px)
Citation preview
Test Driven Development
Marcelo Cure
Where did it come from?
•Kent Beck in 2003•Concepts related to Extreme
Programming
What’s TDD?
•Development technique•Focus on quality•First test then code•Requirements before code•Based on cycles
How does TDD work?
•Developer must have the feature knowledge
•Think baby steps•Write a failing test•Make it pass•Make sure it didn’t break any other test•Refactor•Loop
Benefits
•More tests, less bugs•Code quality•Rare necessity to debug•Leads to modularize your system•Big coverage
Limitations
•Management support is required•Fake tests•Are we really doing TDD?
Environment (talking about Java)•Java•Eclipse•JUnit
Examples – NameRetriever
NameRetrieverTest
public class NameRetrieverTest {private NameRetriever nameRetriever;
@Testpublic void testRetrieveName() {String name =
nameRetriever.retrieveName();Assert.assertEquals("cure", name);}}
NameRetriever
public class NameRetriever {public String retrieveName() { return "";}}
NameRetriever
public class NameRetriever {public String retrieveName() { return "cure";}}
NameRetrieverTest
public class NameRetrieverTest {private NameRetriever nameRetriever;
@Testpublic void testRetrieveName () {Assert.assertEquals("cure",
nameRetriever.retrieveName());}}
That’s all, thanks!