Configuring Black Box BDD with Watin , CassiniDev, NUnit , StoryQ, ASPMVCContrib, Reshaper

Example Source code :



On projects where the view and its contents need to be assured by the developer, we can implement Black Box BDD / Closed Box BDD. This technique is very much akin to acceptance testing with tools such a Selenium or Fitness.

In simple terms we will see in the following  example how to  use Watin and StoryQ to Test drive from the users perspective , the user interface in this case we will be using ASP MVC 3 View.



To implement this technique we need to implement / use a visual driver, the driver will act as a user who interacting with the interface for the system we are trying to build. This will allow the developer to drive out the system under construction from above the user interface.

In this case we are using a web front end and have opted for Watin. We also need a testing framework and i have opted to use StoryQ and Nunit.

In addition we will also be making use for the MVCContrib.Watin helper library

Our package set up will be done with NuGet.

Setting up NuGet

1. Open the Extension Manager


2. Search for the NuGet package and install




3. Add your NuGet references



Basic Solution

Once the solution framework is in place we add a class library in which we then write a few lines of code which drive us to go get NUnit.


NuGet to the rescue


Clicking back in our code file Resharper now helps us to set up the Using for the NUnit references NuGet has added for us.


Enter StoryQ

We now start to implement the Story again we need to use NuGet to get our StoryQ dll also you will note that i have added a tag with my requirement card number in.



With the StoryQ references in place and our using statements fixed up we can go ahead and write our basic story


Next we add our basic scenario im going to go for the happy path as defined on my fictional requirement card.


We can see that i have described the Happy path through the story for my customer or rather i have implemented the fictional BA’s / Agile Customers idea of what the happy path should look like next with a little Resharper magic (Alt+enter on the Red ) i will implement the stubs for the scenario steps.



We then run the test runner (in this case Resharper has use covered there to) and see that our NotImplementedException in each of our steps body translates to a pending status, so were in a good place, to start implementing.

Enter Watin

Next we need to drive the web page so we can emulate a Customer on our web site in best Blue Peter tradition enter stage right my base class.




I have used this base class a number of times and it suits my needs to make use of it we need to add some package references to support Watin so our references now look like this:


Enter CassiniDev (Portable Web server)

We still have some red in the class next lets deal with the WebServer portion of the class for this we will use a the CassiniDev project this basically an attempt to get around the limitations of Cassini ( some of which are documented here:

Cassini dev has to be downloaded from the distribution site and manually added it can be found here: so lets go ahead and download and reference this dll.



Next we need to add a App.Config file and set up Ports and Local Address.


We now add the sections to the App.Config file:


NUnit Configuration to run as STA


CassiniDev & Watin Configuration


Once the configuration file is in place we need to add a reference to the System.Configuration namespace then Resharper we ill help us to fix up our using’s.

The base class should now be completed configured and we can now make use of it to provide the Browser, Server and Driver objects to our tests.

Operation Mapping as follows:

    Final step is to inherit from the base class and write some fixture Setup and TearDown code


    *Note the only other thing you MAY  need to do depending on your OS configuration and if you are running Visual Studio as administrator,  is make sure Cassinidev has permissions to create com objects and isn’t marked as read only.
    **Note If you get a bad Image exception you need to set your test assembly to run as X86


Implementing Steps and Web functionality

Ok so al that is building and we still have our steps reporting pending so were set, we can now turn our attention to making the steps pass.



We now write our implementation for our first step


This now leads use to create our web project im going to go with ASPMVC3 here so lets add that project to our solution and change our App.Config to find our web project.


We need to match our webserver port setting to match out specification config settings and make sure we have a identical end to end experience.

Next we run our test which results in a 404 not found

so we implement our Controller and our View


We rerun our test and we get a fail like so :


So next we hop into the view and set the title text


That’s it we now have  a passing step


Now all that remains is to implement the rest of the step and get a passing green bar.

I have supplied the sample up to this point , i will leave the other steps for you to complete as practise – any problems please drop me a email.


About Beth Martin
software developer

3 Responses to Configuring Black Box BDD with Watin , CassiniDev, NUnit , StoryQ, ASPMVCContrib, Reshaper

  1. Russell East says:

    Love it. going to try it out 😉

  2. George says:

    Great post, thanks for the tips.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: