Your SlideShare is downloading. ×
Testing your applications with mbunit
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

Testing your applications with mbunit


Published on

DDD6. …


Published in: Technology

1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide
  • 2 (2mins)Talk won’t be just on MbUnit, I will be touching on other tools such as Rhino Mocks which help improve testing. Find out how many people are unit testing at the moment? Who are using MbUnit?
  • 7 (5mins)
  • 10 (3mins)
  • 15 (5mins)Sample\\SampleShort demo, covers what is the same with the three frameworks. How they can be executed, some of the cool tools to help. How Resharper can help when developing. Quick and too the point, make sure everyone is up to speed for the rest of the content.DemostrateMSTest, explain how it needs meta data and saves the results in TestResults.DemostrateNunit, show the asserts, how they are different from MSTest. Show how to run the tests using and ReSharper, show failing tests, Show Nunit UI. DemostrateMbUnit, show the assertions, show migrating from Nunit, show UI.Explain test layout, test naming, show ReSharper method template,
  • 16 (1min)Show final application to show the end result so everything has a good idea where we are heading.
  • 24 (8mins)Problems with Rollback/TransactionsNeed to ensure that you have a well known state for the database (demonstrate what happens if you don’t. Fragile tests).InternalsVisibleTo()ExplainLinq to SQL and each Repository (say why I have split it – to isolate and make tests more targetted).Explain that we use repositories so we can mock them as the DataContext cannot be mocked.Explain TestHelper (and Tests)InternalsVisibleTo() to hide some implementation but still have it tested. Hitting the database isn’t bad (just slow), the problems associated with databases is bad. Use TransactionsUse Rollback to make tests easierProblems with Rollback (Auto increment)Solution is DBCC (if auto increment is important to you) – Extract it into external script if you wish.
  • 34 (10mins)Explain Mock ObjectsExplain why they are useful with external services (Payment)(ProductControllerTests)Refactor tests to include validation as that is also important to test. RowTest to enable range testing.Other\\DataDrivenTestsDemonstrate how it could be used. Show the class browser for MbUnit.FrameworkvsNunit to explain the different assertions we have. CustomerControllerTestsHowever, none meet our require. CustomAssert.AreEqual
  • 36 (2mins)
  • 40 (6mins)Show sample WatiN site, explain how it all works. Explain problems with UAC.
  • 42 (2mins)
  • 48 (4mins)ScottHa’sBlogEngine Code.Can’t be demo’ed as it won’t have been released.Explain how it all links together.View is very thin.
  • 50 (2mins)
  • 52 (2mins)
  • 57 (5mins)
  • 58 (1min)
  • 60 (2min)
  • Only if my timings are really out.
  • Transcript

    • 2. Who am I? Test Engineer @ Red Gate Software Based in Cambridge MbUnit Core Commit Member Actively involved with the project for past 18-24 months NxtGenUG Member
    • 3. Agenda Unit Testing and Integration Testing Demo  Tools and Frameworks  Database Layer  Business Layer  User Interface MbUnit v3 and the Gallio Testing Platform Summary
    • 4. Unit Testing Written by the developer Focus on happy day scenarios Ensures everything works as expected Support change of inner workings Support inexperience developers Code is less of a black box Manual testing is boring!
    • 5. Integration TestingWe already have unit tests, why do we also need integration tests? Ideally written by a tester, however generally written by a developer. Unhappy scenarios End-To-End scenarios Does the code meet customer requirements
    • 6. MbUnit 2.4 Advanced testing framework Open Source Developed a number of years ago by Peli (now works for Microsoft Research) Actively developed by a core team of 15
    • 7. Tools and FrameworksDemo•MsTest•NUnit•MbUnit v2.4•TestDriven.Net•ReSharper
    • 8. Scenario Core features of a e-commerce site Users can view products, search and place orders. Linq to SQL for database access 2.0 for UI Web service for payment processing
    • 9. DatabasesDemo•Testing Linq to SQL•Transactions / RollBack
    • 10. Business LayerDemo•Rhino Mocks to mock away from database•Mocking external services•RowTest•Data Driven Tests• MbUnit Asserts•Custom Asserts
    • 11. UI Testing Don’t Automate! At the moment its:  Hard work  Leads to fragile tests  No ‘good’ solution There are solutions available...
    • 12. WatiN - Web Application TestingDemo•Automate web application testing•Supports Ajax•Supports popups and logins.•
    • 13. UI Testing Model View Controller – MVC  Ruby on Rails  MonoRail  MVC Model View Presenter – MVP  Difficult with WinForms/WPF  No other UI framework?
    • 14. MVCCode Demo•Released ‘Shortly’•CTP as part of Futures•Alternative to WebForms – Not areplacement•Designed for testability
    • 15. MbUnit v3 Alpha-1 release soon. Based on the Gallio Testing Platform. Goals  Improved documentation and support  Take testing to the next level  Accommodate more testing styles.
    • 16. Gallio Gallio is an open, extensible, and neutral testing platform. Supports multiple .Net test frameworks including MbUnit, NUnit, NBehave, xUnit.Net and others. Share common components with community More information on the wiki
    • 17. MbUnit v Nunit v MsTest vXUnit Whatever works best for you.... Nunit is simple and straightforward MbUnit is powerful and versatile MsTest – Don’t. Number of problems, 2008 has a number of improvements. Xunit – New boy. Some nice ideas...
    • 18. Resources Books  xUnit Test Patterns – Gerard Meszaros  The Art of Unit Testing - Roy Osherove Blogs  My blog -  Tools  MbUnit –  TestDriven.Net –  Rhino Mocks –  TypeMock –  WatiN –
    • 19. Summary Keep things simple Keep things small Abstraction is key MVC is the future! MbUnit v3 and Gallio are coming soon. Thank you! Slides + Code on my blog
    • 20. Questions