Mocking 101
Upcoming SlideShare
Loading in...5
×
 

Mocking 101

on

  • 3,159 views

Slides from the wellington Dot net user group mocking talk on 2nd April 2008

Slides from the wellington Dot net user group mocking talk on 2nd April 2008

Statistics

Views

Total Views
3,159
Views on SlideShare
3,098
Embed Views
61

Actions

Likes
0
Downloads
35
Comments
0

3 Embeds 61

http://bgeek.net 59
http://www.slideshare.net 1
http://coderwall.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Mocking 101 Mocking 101 Presentation Transcript

  • A brief introduction to test doubles and mocking frameworks
  • Unit testing goals
    • Verification
    • Feedback Speed
    • Focus
    • Isolation
  • Test Doubles
    • 4 types of test double
      • Dummy – We just pass it round and don’t do anything with it
      • Fake – Working implementations but take shortcuts
      • Stubs – Canned answers to expected calls
      • Mocks – Pre programmed with responses and expectations that certain calls should be made
  • Why?
    • Feedback cycle needs to be as small as possible to be useful
    • We need to remove pain points from being necessary
      • Database calls
      • UI
      • Third party libraries
    • We can remove reliance on the rest of the code being complete before knowing the current unit works
  • Mocking frameworks
    • Provide a repeatable way to set up mocks/stubs/fakes with little code cost.
    • Test logic can stay within test
    • We can develop as we test and get immediate results (TDD)
  • Rhino.Mocks
    • One of the most mature and feature complete mocking frameworks
    • Uses castle remoting to mock calls
      • Not able to mock static or sealed calls
    • Fast
    • Record/Replay Syntax
    • Lots of help and code examples available
    • Open Source
  • Typemock Isolator
    • Mature and fully featured
    • Uses IL Generation
      • Can mock static classes and calls
      • Can chain events
    • Commercial licence available for full feature set and support
    • Main commercial mocking framework so features ++
  • Moq
    • New Kid on the block
    • .net 3.5 only
    • No record/replay semantics, just expectations
    • Less code clutter to tests
    • Not feature complete
    • In active development
    • Open source
  • How?
    • It’s time to code
  • Links
    • Rhino Mocks: http://www.ayende.com/projects/rhino-mocks.aspx
    • Typemock: http://www.typemock.com/
    • Moq: http://code.google.com/p/moq
    • Me: http://www.bgeek.net [email_address] http://www.twitter.com/buildmaster