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?
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
40 (6mins)Show sample WatiN site, explain how it all works. Explain problems with UAC.
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.
Only if my timings are really out.
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 project for past 18-24 months NxtGenUG Member Blog.BenHall.me.uk
Agenda Unit Testing and Integration Testing Demo Tools and Frameworks Database Layer Business Layer User Interface MbUnit v3 and the Gallio Testing Platform Summary
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!
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
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
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 access ASP.net 2.0 for UI Web service for payment processing
DatabasesDemo•Testing Linq to SQL•Transactions / RollBack
Business LayerDemo•Rhino Mocks to mock away from database•Mocking external services•RowTest•Data Driven Tests• MbUnit Asserts•Custom Asserts
UI Testing Don’t Automate! At the moment its: Hard work Leads to fragile tests No ‘good’ solution There are solutions available...
WatiN - Web Application TestingDemo•Automate web application testing•Supports Ajax•Supports popups and logins.•http://watin.sourceforge.net
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?
ASP.net MVCCode Demo•Released ‘Shortly’•CTP as part of ASP.net Futures•Alternative to WebForms – Not areplacement•Designed for testability
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
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/
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...
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
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