I have uploaded a small development tool that I put together recently, its called
"Behaviour to Unit Test". Basically it converts code functionality from plain
sentences (or stories) into unit test stub code. You could also think
of it as a cure for TDD writers block!
For an example of the usage, use the Generation -> Fill
out example menu option and hit Convert. Basically it takes
a set of plain language behaviours for an object such as "person":
-
Check that the default values of all string properties are empty
-
The ToString method renders the first and last names
-
If the date of birth is null, calculate age will return -1
-
If the date of birth is not null, calculate age will return a value
...and converts them into something like:
using System;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
namespace Tests
{
[TestFixture]
public class PersonEntityTests
{
private PersonEntity
person;
[SetUp]
public void TestSetUp()
{
person = new PersonEntity();
}
[Test]
[Ignore("Currently
only a unit test stub")]
public void CheckThatTheDefaultValuesOfAllStringPropertiesAreEmpty()
{
}
[Test]
[Ignore("Currently
only a unit test stub")]
public void TheToStringMethodRendersTheFirstAndLastNames()
{
}
[Test]
[Ignore("Currently
only a unit test stub")]
public void IfTheDateOfBirthIsNullCalculateAgeWillReturnMinus1()
{
}
[Test]
[Ignore("Currently
only a unit test stub")]
public void IfTheDateOfBirthIsNotNullCalculateAgeWillReturnAValue()
{
}
}
}
There are C# and VB.NET templates for now. Check it out:
http://www.pksoftware.net/BehaviourToUnitTest/
My intention is to keep the tool small and simple. The main thing I want to add at
the moment is some load/save functionality and drop in the ICSharp.TextEditor for
more friendly editing...