User acceptance testing with SpecFlow

As most of you probably know I'm a huge fan of automated tests.
Of course unit tests help you to find bugs easily in code and api's.
But when we are releasing a product to our customer for acceptance testing of some (or all) features, I also want to know if the product works as expected.

These tests are about behaviour of the application and that's why I prefer BDD (behaviour driven design) over TDD (test driven design). Because it's closer to what our customer understands.

In the end, customer tests are mostly done by testing the UI, because that is what they'll use. Not the code and unit tests.

So we need a way to have automated (integration) tests to test the UI of our application.
This is where SpecFlow comes in. SpecFlow is an open source, .NET based, testing framework which allows you to write BDD and ATDD (acceptance test driven design) style tests. These are much better to understand for the customers than our technical (coded) tests.
SpecFlow is quite similar to Cucumber (which is in Ruby) and uses the same syntax to write your tests.

By adding some extra frameworks you can control the UI from the tests SpecFlow generates for you. This allows you to test the UI for the test scenarios, just like the customer would do. Only faster and much more reliable :-).

Because there is already a lot of material on the internet, I'll just share some links with you without writing a complete demo myself.

Web based applications:

Use SpecFlow with WatiN:
http://blog.stevensanderson.com/2010/03/03/behavior-driven-development-bdd-with-specflow-and-aspnet-mvc/

Windows Forms, Wpf, Silverlight applications

Combining specflow with White to test WPF:
http://www.marcusoft.net/2010/08/using-bdd-with-specflow-wpf-and-white_14.html http://white.codeplex.com

Useful tools while working with the White framework:
UISpy - to lookup the structure of the WPF UI elements
or XamlSpy http://xamlspy.com/

More on UIautomation and WPF quality:
http://msdn.microsoft.com/en-us/magazine/dd483216.aspx http://windowsclient.net/wpf/white-papers/wpf-app-quality-guide.aspx

Windows 8 / WinRT
http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.automation.aspx http://code.msdn.microsoft.com/UI-Automation-Document-24a37c82 http://blogs.msdn.com/b/winuiautomation/archive/2011/05/18/building-ui-automation-client-applications-in-c-and-c.aspx

Ronald Harmsen

I'm a software developer. When I'm not developing software I'm training & coaching other developers, speaking on a conference or fiddling with some technical stuff.

Arnhem, The Netherlands

Subscribe to Ronald to the cloud

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!