introducing tdd

10

Click here to load reader

Upload: vlad-balan

Post on 27-Jun-2015

672 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Introducing TDD

Introducing TDD

Bălan VladRomsoft S.R.L.

Page 2: Introducing TDD
Page 3: Introducing TDD

First Unit Test

DEMO - Calculator

Page 4: Introducing TDD

Red Green Refactor

•Read and understand requirements•Write test that follows requirements•Watch it fail•Write code that makes test pass•Refactor•Repeat

Page 5: Introducing TDD

AAA

• Arrange• Act• Assert

Page 6: Introducing TDD

What we used

• Nunit (http://nunit.org)• ReSharper(http://jetbrains.org)• TestDriven.Net (http://www.testdriven.net)

Page 7: Introducing TDD

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

Page 8: Introducing TDD

Testing the untestable

DEMO

Page 9: Introducing TDD

What’s next

• Mocking frameworks(RhinoMocks, NMock)• Dependency injection

frameworks(StructureMap,Unity)• Other testing frameworks(xUnit, MBUnit,

MSUnit)

Page 10: Introducing TDD

Questions