I am willing to generate some documentation through my test. So far my test look like this :
public class creation_of_a_new_inventory_item : BaseClass<CreateInventoryItem>
{
private Guid _Id = Guid.NewGuid();
private string _Name = "test";
public override CommandHandler<CreateInventoryItem> OnHandle(IRepository repository)
{
return new CreateInventoryItemHandler(repository);
}
protected override IEnumerable<IEvent> Given()
{
yield break;
}
protected override CreateInventoryItem When()
{
return new CreateInventoryItem()
{
Id = _Id,
Name = _Name
};
}
protected override IEnumerable<IEvent> Expect()
{
yield return new InventoryItemCreatedAdded()
{
Id = _Id,
Name = _Name
};
}
[Test]
public void does_not_throw_an_Exception()
{
Assert.IsNull(Caught);
}
}
Unfortunately, when using Nunit, I struggle at getting the informations I need in order to generate some pretty and easy to read documentation.
Is there any of you using Nunit to do that? Could you point me some interesting resource, I would have overlooked on the net? Do you generate documentation out of your test using other tools?
[edit]
My intent was to produce outof my code something like this :
creation of a new inventory item
When I Create Inventory Item
Id:{id},
Name:{name}
Then
Inventory Item is Created ({Success/Fail})
Id:{id},
Name:{name}
And does not throw an Exception ({Success/Fail})
This would do for a first approach. I might change things later, but the main goal would be this. My aim is to be able to write something my boss might understand without letting him enter the code.
[/edit]
Don’t bother with NUnit. Just scan you assembly using reflection. The structure of you test fixture will alway be the same, so it extremely easy to generate documentation. Also you can add smth like Description() formatting method to all of your Commands and Events, in order to get descriptive output with actual values.