NUnit A Pragmatic Approach - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

NUnit A Pragmatic Approach

Description:

Facilitates Automated Unit Testing. Unit testing is code driven ... MEME reaching the masses now. Can Refactor Mercilessly with xUnit. XP and Agile Development ... – PowerPoint PPT presentation

Number of Views:136
Avg rating:3.0/5.0
Slides: 14
Provided by: plo57
Category:

less

Transcript and Presenter's Notes

Title: NUnit A Pragmatic Approach


1
NUnit A Pragmatic Approach
  • by Paul Lockwood (dotnetchap_at_hotmail.com)
  • BCP Warning
  • Please ask questions AT ANY TIME

2
Presentation Summary
  • What is NUnit
  • Pros Cons
  • History of TDD
  • Demonstration
  • Advanced Techniques

3
What is NUnit?
  • Facilitates Automated Unit Testing
  • Unit testing is code driven
  • Part of Daily Build and Smoke
  • Checking-in code is less risky
  • What the Heck is he talking about?
  • Quick Demo

4
Pros and Cons
  • The Good
  • Regression Errors spotted Early
  • Much more testing will happen
  • Takes minutes to test if you support a new
    Service Pack, Database, OS etc
  • The Bad
  • Extra Work (20-50) Can double development time
  • Rework of tests if requirements change
  • The Ugly
  • Management buy in
  • Developer buy in

5
History of xUnit
  • Smalltalk Test Harnesses
  • Smalltalk yet again!
  • JUnit
  • Kent Becks work
  • Refactoring
  • MEME reaching the masses now
  • Can Refactor Mercilessly with xUnit
  • XP and Agile Development
  • Test Driven Development (TDD)
  • Starts becoming High Church
  • Scares many managers

6
Wake Up VS.Net time
  • Imprecise Date Demo
  • Break the code
  • How long that normally have taken to find?

7
NUnit v1 -gtv2.x
  • Now uses Attributes
  • 'The new version is NUnit as it would have been
    done had it been done in C to begin with Kent
    Beck
  • Adding a new Test Class
  • TestFixture
  • Test
  • Doing the tests
  • Assert.Equal(..)
  • Assert.Same(..)
  • Assert.IsTrue(..)

8
More NUnit Attributes
  • Often need to set up data
  • TestFixtureSetUp
  • TestFixtureTearDown
  • Look at Pauls current project
  • Ignore (Refactoring until 7/18/04")
  • Looks useful for large projects
  • Category("LongRunning")
  • Here in v2.2

9
The Bad and Ugly revisited
  • Buy in no one likes extra work
  • Psychology create a buzz, senior developers
    first
  • Clover.Net can Police compliance
  • Moving to new OS, SP etc helps sell
  • How much extra work?
  • White-box vs Black-box testing
  • Personally I mostly only test public APIs

10
Advanced Techniques 1
  • Enterprise Level Testing
  • e.g. A Database is required for tests
  • Create tables/ data in Setup
  • Destroy table/ data in TearDown
  • Need to persist across a tests?
  • Creating a database is slow
  • Singleton Dispose and timer thread works great
    (mail me)
  • Use by all developers is challenging

11
Advanced Techniques 2
  • MVC Design Pattern
  • Code can act more like a user
  • Tests everything but presentation layer
  • May need Mock Objects
  • Debugging with NUnit
  • Very Simple, Tools-gtDebug Process
  • Anyone wish to see this?

12
Final Tips
  • Include nunit.framework.dll in project
  • Make life easier for developers
  • Destroy all Singletons - (IDisposable)
  • And any other state!!
  • Testing stateless classes is easiest
  • nunit.org/attributes.html
  • Simple to follow
  • VS 2005 Team System (WhiteHorse)
  • Migrating NUnit tests is easy

13
Questions Last chance to Heckle
  • Slides are ltTBDgt
  • Marc Cliftons Code Project Articles
  • DotNetRocks.com
  • msdn.microsoft.com/dotnetrocks/
  • June 17 67
Write a Comment
User Comments (0)
About PowerShow.com