introducing tdd
TRANSCRIPT
Introducing TDD
Bălan VladRomsoft S.R.L.
First Unit Test
DEMO - Calculator
Red Green Refactor
•Read and understand requirements•Write test that follows requirements•Watch it fail•Write code that makes test pass•Refactor•Repeat
AAA
• Arrange• Act• Assert
What we used
• Nunit (http://nunit.org)• ReSharper(http://jetbrains.org)• TestDriven.Net (http://www.testdriven.net)
Work
• Create a CurrencyConventor class that knows how to exchange a currency into another currency using an exchange rate.(for example EUR to RON at exchange rate 4.3)
• Only two tests:– When exchange rate is 1.5 and the sum that is
going to be changed is 100– When exchange rate is 2 and sum is 300
Testing the untestable
DEMO
What’s next
• Mocking frameworks(RhinoMocks, NMock)• Dependency injection
frameworks(StructureMap,Unity)• Other testing frameworks(xUnit, MBUnit,
MSUnit)
Questions