views:

175

answers:

4

I have a whole bunch of unit tests written in MbUnit and I would like to generate plain English sentences from test names. The concept is introduced here:

http://dannorth.net/introducing-bdd

This is from the article:

public class CustomerLookupTest extends TestCase {
    testFindsCustomerById() {
        ...
    }
    testFailsForDuplicateCustomers() {
        ...
    }
    ...
}

renders something like this:

CustomerLookup
- finds customer by id
- fails for duplicate customers
- ...

Unfortunately the tool quoted in the above article (testdox) is Java based. Is there one for .NET?

Sounds like this would be something pretty simple to write, but I simply don't have the bandwidth and want to use something already written.

EDIT: Just to clarify the question. I am looking at something that can whiz through existing tests and convert CamelCase function names into sentences. Seems like a perfect job for some sort of Gallio plugin.

So far I somehow found SpecUnit and Jay has suggested BDDDoc. Both of those are behaviour verification frameworks that will require a significant rewrite of the exisitng tests. Our team has made the decision to go with SpecFlow as a main BDD framework and what I was trying to achieve is to generate a report of the existing tests to see how well it fits the BDD approach.

+1  A: 

Have a look at developwithpassion.bdd and bdddoc, developed by JP Boodhoo.

His original blog post on it is here: http://blog.jpboodhoo.com/BDDDoc.aspx

You can find the code on github here: http://github.com/developwithpassion/developwithpassion.bdd

I use his testing framework, and BDDDoc generates plain English HTML reports that even show whether the tests pass or not, by tying into the mbUnit and Gallio reports.

The format, though is that each fixture has a Concern attribute for bdddoc to pick up and group the specs.

My fixtures are named like public class When_the_sound_system_is_off... and my assertions are delegates of type it (from the framework), so they read it should_not_be_spinning_a_compact_disc..., it should_emit_no_sound..., etc.

BDDDoc works off this underscorish syntax, but I think since you are already using mbUnit, you can probably extract the interesting bits of code and tailor it to your needs.

Jay
A: 

StoryQ has quite a good workflow for converting existing unit tests to BDD style - I know that's not directly answering your question but might be worth checking out...

Rob Fonseca-Ensor
+1  A: 

For a presentation last year I have created a small BDD unit testing helper that displays the method names being executed in normal English. The string magic part of it is quite thin so you can surely extract it from it.

Here is my post with the link to the download: http://gasparnagy.blogspot.com/2009/10/devcamp09-behavior-driven-development.html

Gaspar Nagy
+1  A: 

There is a TestDox for .NET It seems fairly recent (2010).

Martin Moene
Aha, exactly what I've been looking for.
Igor Zevaka