0
Ben HallBen@BenHall.me.ukBlog.BenHall.me.ukTESTING YOUR APPLICATIONSWITH MBUNIT
Who am I? Test Engineer @ Red Gate Software Based in Cambridge MbUnit Core Commit Member Actively involved with the pr...
Agenda Unit Testing and Integration Testing Demo   Tools and Frameworks   Database Layer   Business Layer   User Int...
Unit Testing   Written by the developer   Focus on happy day scenarios   Ensures everything works as expected   Suppor...
Integration TestingWe already have unit tests, why do we also need integration tests? Ideally written by a tester, howeve...
MbUnit 2.4 www.MbUnit.com Advanced testing framework Open Source Developed a number of years ago by Peli  (now works f...
Tools and FrameworksDemo•MsTest•NUnit•MbUnit v2.4•TestDriven.Net•ReSharper
Scenario Core features of a e-commerce site Users can view products, search and place  orders. Linq to SQL for database...
DatabasesDemo•Testing Linq to SQL•Transactions / RollBack
Business LayerDemo•Rhino Mocks to mock away from database•Mocking external services•RowTest•Data Driven Tests• MbUnit Asse...
UI Testing Don’t Automate! At the moment its:   Hard work   Leads to fragile tests   No ‘good’ solution There are so...
WatiN - Web Application TestingDemo•Automate web application testing•Supports Ajax•Supports popups and logins.•http://wati...
UI Testing Model View Controller – MVC  Ruby on Rails  MonoRail  ASP.net MVC Model View Presenter – MVP  Difficult w...
ASP.net MVCCode Demo•Released ‘Shortly’•CTP as part of ASP.net Futures•Alternative to WebForms – Not areplacement•Designed...
MbUnit v3 Alpha-1 release soon. Based on the Gallio Testing Platform. Goals   Improved documentation and support   Ta...
Gallio Gallio is an open, extensible, and neutral  testing platform. Supports multiple .Net test frameworks  including M...
MbUnit v Nunit v MsTest vXUnit   Whatever works best for you....   Nunit is simple and straightforward   MbUnit is powe...
Resources Books   xUnit Test Patterns – Gerard Meszaros   The Art of Unit Testing - Roy Osherove Blogs   My blog - Bl...
Summary Keep things simple Keep things small Abstraction is key ASP.net MVC is the future! MbUnit v3 and Gallio are c...
Questions
Upcoming SlideShare
Loading in...5
×

Testing your applications with mbunit

3,159

Published on

DDD6.

http://blog.benhall.me.uk/2007/11/ddd6-post-event.html

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,159
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
18
Comments
0
Likes
1
Embeds 0
No embeds

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 TD.net 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 of "Testing your applications with mbunit"

    1. 1. Ben HallBen@BenHall.me.ukBlog.BenHall.me.ukTESTING YOUR APPLICATIONSWITH MBUNIT
    2. 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 Blog.BenHall.me.uk
    3. 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. 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. 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. 6. MbUnit 2.4 www.MbUnit.com 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. 7. Tools and FrameworksDemo•MsTest•NUnit•MbUnit v2.4•TestDriven.Net•ReSharper
    8. 8. Scenario Core features of a e-commerce site Users can view products, search and place orders. Linq to SQL for database access ASP.net 2.0 for UI Web service for payment processing
    9. 9. DatabasesDemo•Testing Linq to SQL•Transactions / RollBack
    10. 10. Business LayerDemo•Rhino Mocks to mock away from database•Mocking external services•RowTest•Data Driven Tests• MbUnit Asserts•Custom Asserts
    11. 11. UI Testing Don’t Automate! At the moment its:  Hard work  Leads to fragile tests  No ‘good’ solution There are solutions available...
    12. 12. WatiN - Web Application TestingDemo•Automate web application testing•Supports Ajax•Supports popups and logins.•http://watin.sourceforge.net
    13. 13. UI Testing Model View Controller – MVC  Ruby on Rails  MonoRail  ASP.net MVC Model View Presenter – MVP  Difficult with WinForms/WPF  No other UI framework?
    14. 14. ASP.net MVCCode Demo•Released ‘Shortly’•CTP as part of ASP.net Futures•Alternative to WebForms – Not areplacement•Designed for testability
    15. 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. www.MbUnit.com
    16. 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 http://code.google.com/p/mb-unit/
    17. 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. 18. Resources Books  xUnit Test Patterns – Gerard Meszaros  The Art of Unit Testing - Roy Osherove Blogs  My blog - Blog.BenHall.me.uk  CodeBetter.com Tools  MbUnit – www.MbUnit.com  TestDriven.Net – www.TestDriven.net  Rhino Mocks – www.Ayende.com  TypeMock – www.TypeMock.com  WatiN – http://watin.sourceforge.net
    19. 19. Summary Keep things simple Keep things small Abstraction is key ASP.net MVC is the future! MbUnit v3 and Gallio are coming soon. Thank you! Slides + Code on my blog Blog.BenHall.me.uk
    20. 20. Questions
    1. A particular slide catching your eye?

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

    ×