In a word, NAMING! If your going to take just one thing from BDD and apply it to your work I recommend you start with the way BDD practitioners name their tests. Typically you see test names like:
[Test]
public void make_customers_preferred_when_their_purchases_exceed_a_threshold()
{
//…….test implementation
}
Even if your not using BDD I strongly suggest using the sentence like naming convention as it makes understanding what’s going on in a test library that much quicker and simpler. And, whilst your at it, why not check out BDD and give a framework like NBehave a try.
Fiddling with NBehave, I couldn’t help myself. It’s probably only me who’s laughing though. For those Woody Allen fans who remember the film “Love and Death” and the characters of Old and Young Nehamkin.
[Story()]
[Test()]
public void FirstDumbStory()
{
Story dumbstory = new Story(“The Dumbest story ever”);
dumbstory.AsA(“Village Idiot”).IWant(“Fields of Wheat”).
SoThat(“I can frolic”);
dumbstory.WithScenario(“I frolic”)
.Given(“Nice weather”,
“I can go out”, s => { ; })
.When(“I am fully fit”,
“my spirits will be up”, s => { ; })
.Then(“I have outdoor options”,
“and I shall play amongst wheat”, s => { ; });
}
produces the following:
Story: The Dumbest story ever
Narrative:
As a Village Idiot
I want Fields of Wheat
So that I can frolic
Scenario 1: I frolic
Given Nice weather: I can go out
When I am fully fit: my spirits will be up
Then I have outdoor options: and I shall play amongst wheat
1 passed, 0 failed, 0 skipped, took 4.52 seconds.