why you should do test driven development
TRANSCRIPT
Dark Matter Makes 90% of the Universe
UNTESTED CODE IS THE DARK MATTER OF SOFTWARE
(Apparently because it makes up 90% of the software universe) … Uncle Bob
Why untested code is bad?
Test Driven DevelopmentDevelopment Driven by Tests
DebugDriven Development
Debug Driven Development
Test Driven Development
public void Withdraw(double amount) { if(m_balance >= amount) { m_balance -= amount; } else { throw new ArgumentException(amount, "Withdrawal exceeds balance!") } }
[TestMethod]public void Withdraw_ValidAmount_ChangesBalance() { // arrange double currentBalance = 10.0; double withdrawal = 1.0; double expected = 9.0; var account = new CheckingAccount("JohnDoe", currentBalance); // act account.Withdraw(withdrawal); double actual = account.Balance; // assert Assert.AreEqual(expected, actual); } THE TEST IS MORE IMPORTANT THAN THE CODE
Development time
What kind of tests?
The higher we go:
+Expensive+Unreliable+Slower Feedback
Final Message
Thanks!Questions?
References:
http://www.typemock.com/test-driven-development-tdd/http://butunclebob.com/ArticleS.UncleBob.UntestedCodeDarkMatterhttp://pt.slideshare.net/alextercete