Title: Test Driven Development Introduction
1Test Driven DevelopmentIntroduction
- Roy Osherove
- Microsoft MVP
- Senior Consultant, Magen
- Agile Development Specialist
2Roy who?
- Agile Development Specialist Magen
- Consultant, Speaker, Writer, Blogger
ISerializable.com - Articles, resources ideas and questions
- Contact me Roy_at_Magen.com (or get my card)
- Agile Workshops at Magen
- Check out your flyers
- Starting a new project? Want to go Agile? Not
sure how? Magen can help. - And
3Public Announcements
- Agile Israel user group opens!
- All things agile
- Roundtable discussions about problems and
solutions - Learning from each other
- Interested? Agile_at_Osherove.com
- Community TDD workshops at Magen
- Get at taste for TDD - Hands on!
- Community as in free!
- 10-12 people at a time
- TDD_at_Osherove.com
4Agenda
- Introduction to TDD
- A simple TDD demo
- The NUnit Framework
- Testing Attributes
- NUnit Addin
5Putting TDD in Context
- Engineering methodologies (waterfall for
example..) - Agile (flexible lightwheight) Methodologies
- eXtreme Programming
- Test Driven Development
6The Methodologies
- XP (extreme programming)
- The Crystal family
- MSF(Agile)
- Highsmith's ASD (Adaptive Software Development)
- Scrum
- Feature Driven Development
- DSDM (Dynamic Systems Development Method)
- Rational Unified Process? (dX)
7Test Driven Development
- What is unit testing?
- Why do I want it?
- Whats NUnit?
- Why test first?
8A Unit Test is a testof a small functional piece
of code
Public bool IsLoginOK(string user, string
password) //
9Unit Testing makes your developer lives easier
- Easier to find bugs
- Easier to maintain
- Easier to understand
- Easier to Develop
10You have already done Unit testing
- Not structured
- Not Repeatable
- Not on all your code
- Not easy to do as it should be
- A framework is missing
11The xUnit Frameworks
- Original was for SmallTalk
- Kent Beck and Erich Gamma
- Ported to Various languages and platforms
- JUnit, CppUnit, DUnit, VBUnit, RUnit, PyUnit,
Sunit, HtmlUnit, - Good list at www.xprogramming.com
- Standard test architeture
- Introducing NUnit
12How we use NUnit
- Write Tests
- Make it easy to create and organize tests
- Reference an assembly, spread some attributes,
youre done - Run Tests
- Allow running all of our tests, a group or just
one. - From command line or GUI
- Review Results
- Immediate Pass/Fail feedback
- Details on each failure
- Able to generate XML reports
13The 3A Pattern
14Demo
15NUnit Framework components
- Test Fixtures
- Tests
- Assertions
- Setup
- TearDown
- TestFixtureSetUp
- TestFixtureTearDown
- Ignore
- ExpectedException
- Suites(namespaces)
- Extensibility (new)
16Demo
17Test-Driven Development
- Make it Fail
- No code without a failing test
- Make it Work
- As simply as possible
- Make it Better
- Refactor
18Demo
- Add(x,y)
- Zero throws exception
- Can read files with numbers
19Nunit -Addin
20Much more to learn
- Database testing
- Mock objects
- Creating customized test cases and suites
(Extensibility) - Agile management
- Continuous Integration( managing the build
process) - The future VS.NET 2005
- Roy_at_Magen.com
21Embracing TDD in your organization
- You dont have to start big
- Start new tasks with TDD
- Add Tests to code that you need to change or
maintain but only to small parts. - Proof of concept Spike Solution
- Growing an architecture
- UML as a communication aid
- Project Handover
- The Architect role (The will to design)
221/3 Web Siteshttp//www.testdriven.comhttp//www
.xprogramming.comAgileAlliance.com ExtremeProgram
ming.org Blogshttp//dotnetjunkies.com/WebLog/da
rrell_nortonhttp//www.peterprovost.orghttp//we
blogs.asp.net/nunitaddinhttp//weblogs.asp.net/ja
mesnewkirk http//www,iserializable.com
Roy_at_Magen.com
23Refactoring Resources
- 2/3
- Refactoring.com
- http//www.refactoring.com/
- The Father of Refactoring
- http//www.martinfowler.com
- Microsoft Refactoring Developer
- http//weblogs.asp.net/jaybaz_ms/
- C Refactoring Tutorial
- http//geocities.com/bryantrsmith/refactoring/
- Refactoring to Patterns
- http//www.industriallogic.com/xp/refactoring/
24Additional Resources
- 3/3
- Mailing Lists
- Yahoo Group testdrivendevelopment
- Yahoo Group agiledotnet
- Books
- Test-Driven Development in Microsoft .NET James
Newkirk and Alexei Vorontsov - Test-Driven Development, by Example Kent Beck
- Test-Driven Development, A Practical Guide
David Astels - Unit Testing in Java, Johannes Link
25Questions?
- Roy_at_Magen.com
- www.iserializable.com