Wednesday 27 January 2010

Unit Test Naming Conventions

Unit test names can be horribly long and misleading at times. I particularly hate...

AMethod_That_IS_Long_n_HasUnderscores_AT_Random_Points

Naming them in a concise, clear manner is important but consistency is the key. I use a simple convention to help me with naming my test methods that I've seen others use.

// MethodNameBeingTested_Input_Output
ToySearch_WhenNoToysFound_ReturnsZeroToysFoundView

Steve Sanderson suggested (on his blog) that we call this naming convention SSR (Subject, Scenario, Result), sounds good to me :)

No comments:

Post a Comment