Your SlideShare is downloading. ×
Battle of The Mocking Frameworks
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Battle of The Mocking Frameworks

1,550
views

Published on

Session from NDC London 2013 …

Session from NDC London 2013

Writing unit tests is hard, isn't it? you need an entire set of tools just to start. One of the crucial decisions when building this set is picking up a mocking framework.
But BEWARE! what you choose has the ability to make you or break you!
Come to the session and see Dror Helper, once a mocking framework developer, show the good and the bad of different mocking frameworks (free and commercial) and make them battle to the death!

Published in: Technology, Education

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,550
On Slideshare
0
From Embeds
0
Number of Embeds
12
Actions
Shares
0
Downloads
17
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Possible changes:CUT adds/remove a parameterDependency API changeAdd call to the same dependency without specifying in testChange to another overload of the same function
  • Transcript

    • 1. Battle of the Mocking Frameworks Dror Helper drorh@oz-code.com | @dhelper | http://blog.drorhelper.com
    • 2. About.ME • Developing software (professionally) since 2002 • Disclaimer: I used to work @Typemock • Blogger: http://blog.drorhelper.com
    • 3. This is a unit test [Test] public void AddTest() { var cut = new Calculator(); var result = cut.Add(2, 3); Assert.AreEqual(5, result); }
    • 4. Real code has dependencies Unit test Code under test Dependency Dependency
    • 5. The solution - Mocking Unit test Code under test Fake object(s) Dependency
    • 6. What is a “Mock”? “mock objects are simulated objects that mimic the behavior of real objects in controlled ways” [From Wikipedia] I prefer to call them “Fakes”
    • 7. What Mocking framework can do for you? • Create Fake objects • Set behavior on fake objects • Verify method was called • And more...
    • 8. Meanwhile in the .NET world Open source •FakeItEasy •Moq •NMock3 •nSubtitute •Rhino Mocks Free •MS Fakes Commercial •Isolator •JustMock
    • 9. Choosing the right framework is crucial • Married into your (test) code • Saves/waste development time • Affects design
    • 10. Round 1 - API
    • 11. Mock-Demo Request Response Read Data DB
    • 12. API summary Readability SPE Builder Parameters Error msg Moq + No Yes Explicit + Rhino-Mocks + No No Explicit - FakeItEasy + Yes No Explicit + nSubtitute + No No Explicit + NMock3 - No Yes Explicit ? Isolator + Yes No Implicit + JustMock + Yes No Explicit - MS Fakes - No Yes Explicit N/A
    • 13. Round 2 - Robustness Code under test API changes • Method signature • Method name Code under test internal changes • Unexpected call to fake • Return value from unspecified method Future proof
    • 14. Round 3 Unconstrained
    • 15. Constrained • Fake by inheritance • Force architecture Real object – Dependency injection (DI) – Code by interfaces (LSP) • Wrapping of the unfakeable Fake object
    • 16. Unconstrained • Profiler API based • Can fake almost anything Real Object – 3rd party systems – Legacy code • Design your code - not for testability • Can be used as if they are constrained Dependency Fake
    • 17. Constraint •NMock3 •FakeItEasy •nSubtitute •Moq •RhinoMocks Unconstraint •Isolator •JustMock •MS Fakes
    • 18. Round 4 - deployment
    • 19. Deployment – the bottom line Constraint Isolator JustMock MS Fakes Dev machine Nothing (NuGet) Install on each machine. Auto-run correct version Install on each machine. Visual studio 2012/2013 Build Server Nothing Install or use AutoDeploy Install on each machine. Only TFS (> 2012) Run tests on build machine Just run it Environment vars TMockRunner Build Tasks Environment vars JustMockRunner Build Tasks Only TFS (> 2012) Profilers Support Works! Automatic Linker Use Linker Only VS11 profilers
    • 20. Which framework is better?
    • 21. Dror Helper C: 972.05.7668543 e: drorh@oz-code.com B: blog.drorhelper.com w: www.ozcode.net