BDD Spec Generator
I've written a little console application to convert NUnit test result output from BDD style test fixtures into a simple spec text file. The spec text file output is basically a human readable file that will be useful to departments in your business other than the developers themselves, such as - QA and Project Managment. It is something I'm starting to promote in my workplace and hoping that it helps with the development and feedback process. Below I explain the process I go through to create these spec documents.
1. The Test Fixture
First you have your test fixture:
namespace MattCalla.PineappleTinFeet.PineappleSpecs
{
[TestFixture]
public class When_a_pineapple_is_created
{
[TestCase]
public void The_pineapple_should_be_wearing_a_hawaiin_shirt()
{
}
[TestCase]
public void The_pineapple_should_have_a_default_name_of_snapple()
{
}
[TestCase]
public void The_pineapple_should_have_a_tin_can_on_both_feet()
{
}
}
[TestFixture]
public class When_a_pineapple_starts_walking
{
[TestCase]
public void The_clinking_sound_of_tin_feet_should_be_heard()
{
}
}
}
2. The NUNit Test Results
After your tests are run, the NUnit test results are generated:
<test-suite name="MattCalla" success="True" time="..." asserts="0">
<results>
<test-suite name="PineappleTinFeet" success="True" time="..." asserts="0">
<results>
<test-suite name="PineappleSpecs" success="True" time="..." asserts="0">
<results>
<test-suite name="When_a_pineapple_is_created" success="True" time="..." asserts="0">
<results>
<test-case name="The_pineapple_should_be_wearing_a_hawaiin_shirt" executed="True" success="True" time="..." asserts="1" />
<test-case name="The_pineapple_should_have_a_default_name_of_snapple" executed="True" success="True" time="..." asserts="1" />
<test-case name="The_pineapple_should_have_a_tin_can_on_both_feet" executed="True" success="True" time="..." asserts="1" />
</results>
</test-suite>
<test-suite name="When_a_pineapple_starts_walking" success="True" time="..." asserts="0">
<results>
<test-case name="The_clinking_sound_of_tin_feet_should_be_heard" executed="True" success="True" time="..." asserts="1" />
</results>
</test-suite>
</results>
</test-suite>
</results>
</test-suite>
</results>
</test-suite>
3. The Spec document output
After running SpecBuilder.exe, you will get something like:
PineappleSpecs
When a pineapple is created
- The pineapple should be wearing a hawaiin shirt
- The pineapple should have a default name of snapple
- The pineapple should have a tin can on both feet
When a pineapple starts walking
-The clinking sound of tin feet should be heard
4. Using with NAnt/CruiseControl.NET
I've configured this to run automatically everytime a build is triggered in my cruise control server. I just placed the following in the build <target> of my NAnt build script which gets triggered by CruiseControl.NET:
<exec basedir=".\Tools\SpecBuilder"
useruntimeengine="true"
workingdir="${builddirectory}"
program="SpecBuilder.exe"
commandline="Tests-Result.xml"
failonerror="false" />
Obviously just adjust the directories to actual locations on your machine, and ensure the 'commandline' attribute points to the file where your NUnit test results output to.
Soon I will release the source code for this (after cleaning it up a bit - at the moment it's a bit all over the place as this was done in about 10 minutes as a proof of concept), and hopefully people can add there 2 cents worth to it.
In the mean time I'm hoping to get some feedback on what people think about this, and whether you think it would really be useful to the business or just some more documentation that will get ignored.






Give please. Humor is always based on a modicum of truth. Have you ever heard a joke about a father-in-law?
I am from Japan and bad know English, give please true I wrote the following sentence: "Com provide you with cheapest airline tickets to india, international airline discount tickets other related information at your finger tips."
Thank you very much
Reply to this