A tool that converts functional behaviour from plain language phrases into unit test stubs for test driven development. Now you can also "paste in" current unit test code and the phrases will be extracted - the full round trip!
A simple tool to help focus on functional behaviour while creating unit tests. This is not a BDD tool, its not trying to compete with Behave# (in the slightest!). The focus is the functional behaviour of test first code.
The latest release build can be downloaded here: PKSoftware.BehaviourToUnitTest.zip (v1.0.0.3, 127kb, requires .net v2)
The tool with an intended objects behaviours in plain language.
The tool after converting the behaviours fom plain language into a C# unit test stub.
TDD is great but sometimes I need help to direct the creation of the unit tests. I believe that where possible and appropriate, unit test code should document the system they test. That said, the name of the test fixture and its method names have the largest bearing on this. The finer details are in the unit test code but the naming is key. Also - the more I use it the more I like the underscore style...
I find a systems unit tests if written well to be in many cases the best source of documentation of the system. Unit tests are good but if the structure is bad or misleading they can confuse rather than help other developers.
You may have unit tests that cover every aspect of the system but if with 100% cod coverage but if the structure is not there you are missing out on a big piece of the picture.
I created a simple tool - Behaviour to Unit Test. It sits outside the IDE as a standalone windows application, this is intentional - to get away for the source code while deciding what to test. This tool is deliberately minimalist, simple is good!
In essence it simply lets me focus on the development of stories for a piece of functionality. Currently I define a test type (i.e. a class) and name it - for example "PersonEntity" with a test instance named "person".
Then I define a list of stories for that class. A story is a single line (to keep it simple). I write the stories as plain sentences:
Selecting "generate" will render the variables and stories into a unit test stub using some simple templates. The story phrases are converted into Pascal cased method calls (or underscored in place of the spaces).
Using the example above will create a unit test stub similar to the following (in C# using the Pascal case option):
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() { } } }
Or, a VB.NET example using the underscore style option.
_ Public Class PersonEntityTests Private person As PersonEntity _ Public Sub TestSetUp() person = new PersonEntity() End Sub _ _ Public Sub Check_that_the_default_values_of_all_string_properties_are_empty() End Sub _ _ Public Sub The_ToString_method_renders_the_first_and_last_names() End Sub _ _ Public Sub If_the_date_of_birth_is_null_calculate_age_will_return_minus_1() End Sub _ _ Public Sub If_the_date_of_birth_is_not_null_calculate_age_will_return_a_value() End Sub End Class
The format of a template filename is: "<test system>.<template type>.<language>.Template.txt" Where:
(TODO...) The following template variables are replaced in the template files. Template files are loaded each time the generate option is executed.