exceptionz

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

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>