Automated functional tests using Watin and MSpec

I am conducting a spike for a couple of evening on the way we might automate our functional tests at Jobping

I started with Watin and MSpec and the MSpec excellent plugin for ReSharper 5 which gives the following great outputs directly from Visual Studio


After some discussion with Alexander Groß (Thanks for your help ;) to gain some knowhow about MSpec I finally managed to have some automated functional tests running like this:

public class when_user_search_using_keywords : WebBaseSpec
    const string Keywords = "C#";
    static SearchScreenObject searchScreenObject;
    static ResultScreenObject resultScreenObject;

    Establish context = () =>
            searchScreenObject = new SearchScreenObject(Browser);
            resultScreenObject = new ResultScreenObject(Browser);

    Because of = () => searchScreenObject.Search(Keywords);

    It should_direct_user_to_results_page = () =>
        Browser.Uri.Route().ShouldMapTo<HomeController>(x =>
            x.Search("AU", new SearchRequest { Keywords = Keywords}));

    It should_fill_search_textbox_with_keywords_entered_by_user = () =>

I think it talks for itself!

Remarks to note:

  1. SearchScreenObject and ResultScreenObject represents an isolation layer between my tests and objects that are present on the web pages. This helps in the case you decide to change an id of an element
  2. I use MvcContrib ShouldMap to ensure that the browser navigates to the correct destination page which add another isolation layer and let me change my URL without impacting my tests

It is really funny to see the browser opening and clicking automatically, typing texts…

Hopefully, at the end this will replace our smoke test document and quite some time of manual testing.

About Laurent

Laurent Kempé

Laurent Kempé is the editor, founder, and primary contributor of Tech Head Brothers, a French portal about Microsoft .NET technologies.

He is currently employed by Innoveo Solutions since 10/2007 as a Senior Solution Architect, certified Scrum Master and Founding Member.

Founder, owner and Managing Partner of Jobping, which provides a unique and efficient platform for connecting Microsoft skilled job seekers with employers using Microsoft technologies.

Laurent was awarded Most Valuable Professional (MVP) by Microsoft from April 2002 to April 2012.

JetBrains Academy Member
Certified ScrumMaster
My status


This is a Flickr badge showing public photos and videos from Laurent Kempé. Make your own badge here.

Month List

Page List