Thoughts on Technology, Methodology and Programming.

Archive for October, 2005

Test List and Naming Test

Posted by Marcus Wyatt on 24 October 2005

Many people think that Test Driven Development is about testing, but this is actually a fallacy. TDD is all about specification and design, you write a specification that nails down a small aspect of behavior in a concise, unambiguous and executable form.

As the developer you need to stop thinking in terms of tests. You will need to think about what specification, behavior or functionality the test are describing. And here is where it becomes critical to name your test with an intent describing name to communicate the behavior you are implementing with the test.

The following suggestions help to construct a good test name:

  • Use the “Should/Should Not” construct to help you describe the behaviour

e.g. Create a Stack and verify that IsEmpty is true.

[New_Stack_Should_Be_Empty] or [NewStackShouldBeEmpty]

  • Use the [desired-result][coordinator][conditions] pattern to specify the behavior.

e.g. Create a Stack and verify that IsEmpty is true.

– Desired Result: IsEmpty is true

– Coordinator: when

– Conditions: Stack first created

[IsEmptyIsTrue_When_StackCreated] or [IsEmptyIsTrueWhenStackCreated]

Stylistically I prefer the underscore to separate the actors in the method names, it makes reading the methods easier.

tags: ,

Currently listening to: – Winamp *** 68. Timo Maas – Notrance

Posted in BDD, TDD | Leave a Comment »

Pondering Agile…

Posted by Marcus Wyatt on 17 October 2005

Jay Kimble had a rant about the Waterfall process and here are some quotes from his post:

“I got into IT to program computers; I love programming. I didn’t get into IT so that I could write technical specifications. “

The first thing to hit us was the change control process which can be a fairly lengthy process… one size fits all; if you are deploying a small intranet site or a major mainframe change it all travels through the same process. Change management is absolutely essential (don’t get me wrong), but the problem has been that the company itself is reactive, so every mistake by someone ends up causing more paperwork for everyone else. Next we added Design docs, and from there who knows where, but we’re pretty much in full SLDC.

IMO, waterfall (SDLC) looks like “death by paperwork” to me.

I think Jay has a point here… These business management processes are overbearing and waste a lot of time. Just the other day I’ve spent two weeks updating a technical spec and only spent a week building the system. I could have done the system without updating the spec and would have saved two weeks, where we could have spent on additional features for the system.


Currently listening to: cevin fisher – it’s all good – Winamp *** 501. cevin fisher – it’s all good

Posted in Agile, XP | Leave a Comment »

Behavior Driven Development

Posted by Marcus Wyatt on 1 October 2005

After reading Dave Astels post on Behavior Driven Development called “A New Look at Test Driven Development”and having a listen to his podcast on Behavior Driven Development that he did at Agile 2005 with the “Agile Toolkit Podcast” team, I started to become more curious…

So I got my “Test-Driven Development in Microsoft.NET” book and the chapter 2 example looked like a good example for my first attempt at BDD. I selected the Unbounded Stack Test list and thought about what I’ll name the test method that I’ll use when I am writing test to implement the requirements.

Here is the list of tests and test method names:

  • Create a Stack and verify that IsEmpty is true. = New_Stack_Should_Be_Empty
  • Push a single object on the Stack and verify that IsEmpty is true. = Push_Object_Stack_Should_Not_Be_Empty
  • Push a single object, Pop the object, and verify that IsEmpty is true. = Push_Pop_Object_Stack_Should_Be_Empty
  • Push a single object, remembering what it is, Pop the object, and verify that the two objects are equal. = Push_Pop_Object_Should_Be_Same
  • Push three objects, remembering what they are; Pop each one, and verify that they are removed in the correct order. = Push_Pop_Multi_Object_Should_Be_Same
  • Pop a Stack that has no elements. = Pop_Empty_Stack_Should_Throw_Exception
  • Push a single object and than call Top. Verify that IsEmpty is false. = Push_Top_Stack_Should_Not_Be_Empty
  • Push a single object, remembering what it is; and than call Top. Verify that the object that is returned is the same as the one that was pushed. = Push_Top_Object_Should_Be_Same
  • Call Top on a Stack with no elements. = Top_Empty_Stack_Should_Throw_Exception

Now if we have a look at the source code for the first two tests the intent becomes as clear as daylight:

public void New_Stack_Should_Be_Empty()
public void Push_Object_Stack_Should_Not_Be_Empty()
   stack.Push("first element");
   Assert.IsFalse(stack.IsEmpty, "After Push, IsEmpty should be false");

I know Dave is working on a new framework for BDD, but I think that in the mean time I’ll start writing my TDD test using method names that is more BDD. This does help with making the intent of the test a lot clearer.

tags: , ,

Currently listening to: wer mix) – Winamp *** 11. Balearic Bill – Destination Sunshine (DJ Tiësto Power mix)

Posted in BDD, TDD | Leave a Comment »