A while back I did the user group sessions and cloud case video about Behaviour Driven BizTalk Development and talked about how you could use SpecFlow with Visual Studio 2010, BizUnit 4 and BizTalk 2010 to create acceptance tests for your solution.
The video is on the below link:
Part 1: http://cloudcasts.cloudapp.net/ViewWebcast.aspx?webcastid=2520897495056204879
Part 2: http://cloudcasts.cloudapp.net/ViewWebcast.aspx?webcastid=2520897493960073864
Of the many advantages of this approach one of the best ones was the benefits of using acceptance tests as documentation of the solution. Well written acceptance tests can become excellent, accurate and tested documentation which sits with the code.
So while all is good in BizTalk 2010 world, I've recently been working with one of my BizTalk 2006 customers and wanted to explore how we could do something to bring these advantages to BizTalk 2006. The key limitation for BizTalk 2006 is that Specflow did not support Visual Studio 2005. A few weeks ago I talked in a separate blog article about how we could use xml comments in the BizUnit 2 xml files to be able to annotate our existing tests so that we have a structure which gives a good idea of the intention of a test to sit alongside the implementation.
So while we are now in a better place I wanted to convert the comments from these xml files into some kind of documentation which I can easily distribute to none BizTalk developers. To solve this problem I have developed an MsBuild task which you can point to directories which contain your BizUnit tests and then it will recursively look for files in those directory which contain BizUnit tests.
When a test is identified we simply use some regular expressions to pull out the feature name, scenario name and gherkin statements I talked about previously and then produce html reports documenting each feature.
Here is an example of a documented test:
Here is an example of the usage of the msbuild task:
<!-- Gherkin Documentation of BizUnit -->
You will need to do the normal importing of an MsBuild task and also setup the properties and item collection for the folders to inspect for tests.
Here is an example of the produced html report:
A couple of points to note:
- If you have some BizUnit tests which do not have the comments in then they are marked in a file canned .html which contains the undocumented tests
- We plugged the task into our MsBuild process so that everytime we produce a build of code the documentation is also included with it.
- Each html file will contain all of the documentation for scenarios which were marked with the same feature name.
Hopefully this will help lower the cost of ownership of your existing solutions and help when people join and leave your development team to help make your BizUnit tests easier to understand.
Download the bits
The code and bits for this article are available in my skydrive samples folder on the following link: