NUnit version 2'1 for 'NET Test driven development - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

NUnit version 2'1 for 'NET Test driven development

Description:

Idea behind test driven development. How to start using test driven development ... has been completely redesigned to take advantage of many .NET language ... – PowerPoint PPT presentation

Number of Views:428
Avg rating:3.0/5.0
Slides: 16
Provided by: seanpj
Category:

less

Transcript and Presenter's Notes

Title: NUnit version 2'1 for 'NET Test driven development


1
NUnit version 2.1 for .NETTest driven
development
2
Overview
  • Idea behind test driven development
  • How to start using test driven development
  • Specifically NUnit v2.1
  • Examples
  • ApplicationTracker (Developed by BSG)
  • RemotePVR (Developed by Sean P. Jensen)

3
Basic ideas in Test Driven development
  • Most aspects of an application can be tested
  • Test then develop
  • Create a test that fails
  • Fix failure
  • Repeat
  • Separate everything into its components
  • Separate those components into its base classes
  • Test each class

4
Introducing NUnit v2.1 for .NET
  • http//sourceforge.net/projects/nunit or
    http//www.nunit.org/
  • Can test any .Net Language that is compiled into
    the CRL (Common Runtime Language)
  • Initially ported from JUnit

5
Introducing NUnit v2.1 for .NET
  • NUnit has been completely redesigned to take
    advantage of many .NET language features
  • custom attributes
  • other reflection related capabilities
  • NUnit brings xUnit to all .NET languages

6
Break into test suites Fixtures
  • View application as
  • A single TestFixture or Multiple TestFixtures
  • Separate TestFixtures in to simple Tests
  • Create one test for each possible operation from
    an object
  • Test each operation
  • Fix all errors thencontinue testing

7
Nunit testing framework
  • Required attributes
  • TestFixture
  • Used to indicate that a class contains test
    methods
  • Test
  • Used to indicate that a method within a test
    fixture should be run by the Test Runner
    application

8
Nunit testing framework (cont.)
  • Optional attributes
  • TestFixtureSetUp
  • Used to indicate a setup method that will be ran
    once before all other tests. This is the first
    method that is called before the tests are
    started.
  • TestFixtureTearDown
  • Used to indicate a tear down method that will be
    ran once after all other tests have run. This is
    the last method that is called after all the
    tests have finished.

9
Nunit testing framework (cont.)
  • SetUp
  • Used to indicate a setup method should be ran
    before each of the tests
  • TearDown
  • Used to indicate a tear down method should be ran
    after each of the tests are ran

10
Nunit testing framework (cont.)
  • ExpectedException(typeof(Exception))
  • When you want an exception to be thrown
  • Will only pass if exception type was throw
  • Ignore(Not ready for primetime")
  • Used when a test is not ready, or you dont want
    the test to be ran

11
Attribute Listing
  • TestFixture
  • TestFixtureSetUp
  • TestFixtureTearDown
  • Test
  • SetUp
  • TearDown
  • ExpectedException(typeof(Exception))
  • Ignore(message)

12
Example code
  • Application Tracker
  • Existing Tests
  • RemotePVR Client C
  • Create some tests See its easy!

13
My views on this development process
  • The Good
  • Application object model
  • Testing data retrieval
  • Database, XML file, Files from hard drive
  • Testing data and object manipulation
  • Easy to retest modifications to classes
  • Easy to retest all interactions with a class, if
    the test already exist
  • Application is usually more stable when finished
  • Easy to know when a class is done
  • All tests pass without issue

14
My views on this development process
  • The Bad
  • Not easy to test webpages difficult
  • Most methods require post back, not supported in
    Nunit as far as I can tell
  • Takes time to set tests up
  • Must have a very sound Object Model before
    starting on a project
  • Must take the time to maintain and keep the tests
    up to date
  • One more thing to debug

15
Sources/References
  • Nunit documentation
  • http//www.nunit.org/
  • http//www.codeproject.com/dotnet/tdd_in_dotnet.as
    p
  • Pie chart copied from http//www.maricopa.gov/sbea
    p/gra/enforcement-pie-chart.gif
  • Personal experiences
Write a Comment
User Comments (0)
About PowerShow.com