Your SlideShare is downloading. ×
0
Mock Objects and Mock Frameworks Andriy Buday
Weather Service Example <ul><li>It is still raining in Lviv </li></ul><ul><li>So how to test sunny weather? </li></ul>Intr...
What are Mock Objects? <ul><li>Any dummy object that stands in for a real object that is not available, or is difficult to...
Why use mock objects? <ul><li>Help keep design decoupled </li></ul><ul><li>Check code’s usage of another object </li></ul>...
Why use mock objects? <ul><li>Promote interface-based design </li></ul><ul><li>Refine interfaces </li></ul><ul><li>Test un...
When to use Mock Objects? <ul><li>Non-deterministic or random behaviour </li></ul><ul><li>Difficult setup </li></ul><ul><l...
Diff Between Mocks and Stubs <ul><li>Dummy </li></ul><ul><li>are not really used </li></ul><ul><li>Fake </li></ul><ul><li>...
Warehouse Example <ul><li>Regular tests </li></ul><ul><li>Nmock </li></ul><ul><li>Rhino Mocks </li></ul><ul><li>Paskal Moc...
Rhino Mocks <ul><li>Dynamic mocks </li></ul><ul><li>on concrete class </li></ul><ul><li>mock some methods </li></ul><ul><l...
Questions?
Upcoming SlideShare
Loading in...5
×

Mock Objects Presentation

1,031

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,031
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
15
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Mock Objects Presentation"

  1. 1. Mock Objects and Mock Frameworks Andriy Buday
  2. 2. Weather Service Example <ul><li>It is still raining in Lviv </li></ul><ul><li>So how to test sunny weather? </li></ul>Introduction…
  3. 3. What are Mock Objects? <ul><li>Any dummy object that stands in for a real object that is not available, or is difficult to use in a test case </li></ul><ul><li>A mock object must have ability to set up expectations and provide a self-validation mechanism </li></ul>
  4. 4. Why use mock objects? <ul><li>Help keep design decoupled </li></ul><ul><li>Check code’s usage of another object </li></ul><ul><li>Make tests run faster </li></ul><ul><li>Make it easier to write code for problematic resources </li></ul><ul><li>Defer having to write a class </li></ul><ul><li>Test components in isolation from the rest of the system </li></ul>
  5. 5. Why use mock objects? <ul><li>Promote interface-based design </li></ul><ul><li>Refine interfaces </li></ul><ul><li>Test unusual, unlikely and exceptional situations </li></ul>
  6. 6. When to use Mock Objects? <ul><li>Non-deterministic or random behaviour </li></ul><ul><li>Difficult setup </li></ul><ul><li>Behavior hard to cause </li></ul><ul><li>Slow real objects </li></ul><ul><li>UIs </li></ul><ul><li>Test needs to make queries not supported by real object </li></ul><ul><li>Non-existent real objects </li></ul>
  7. 7. Diff Between Mocks and Stubs <ul><li>Dummy </li></ul><ul><li>are not really used </li></ul><ul><li>Fake </li></ul><ul><li>have working implementation but not real </li></ul><ul><li>Stubs </li></ul><ul><li>pass prepared answers </li></ul><ul><li>Mocks </li></ul><ul><li>provide expectation logic </li></ul>
  8. 8. Warehouse Example <ul><li>Regular tests </li></ul><ul><li>Nmock </li></ul><ul><li>Rhino Mocks </li></ul><ul><li>Paskal Mock </li></ul>
  9. 9. Rhino Mocks <ul><li>Dynamic mocks </li></ul><ul><li>on concrete class </li></ul><ul><li>mock some methods </li></ul><ul><li>Partial mocks </li></ul><ul><li>on class/interface </li></ul><ul><li>every member should be mocks </li></ul><ul><li>compiler default for not expected methods called </li></ul><ul><li>Strict mocks </li></ul><ul><li>similar to partial </li></ul><ul><li>test fail if not expected method was called </li></ul>Rhino can kill weather dilemma easily
  10. 10. Questions?
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×