Thoughts on Technology, Methodology and Programming.

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


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: