≡ Menu

Which convention should we use for naming unit tests?

I am currently reading The Art of Unit Testing by Roy Osherove. He recommends the following naming convention for tests:
[MethodUnderTest]_[Scenario]_[ExpectedBehaviour]

Which I am glad is similar to that which I’ve adopted in the past:
[MethodUnderTest]_Should[ExpectedBehaviour]_When[Scenario]

I think the latter makes for easier reading. Though I admit that the convention recommended by Roy makes for easier ordering/categorising of tests by scenario.

Whichever method is chosen, I think it’s important that the same standard is adopted by the whole team.

Be Sociable, Share!
{ 0 comments… add one }

Leave a Comment