XNSIO
  About   Slides   Home  

 
Managed Chaos
Naresh Jain's Random Thoughts on Software Development and Adventure Sports
     
`
 
RSS Feed
Recent Thoughts
Tags
Recent Comments

My Test Naming Conventions: More Examples

Other’s Naming Convention My Naming Convention
itShouldSetAccountToLoggedInWhen-
PasswordMatches
matchingPasswordLogsYouIn
itShouldSetAccountToRevokedAfterThree-
FailedLoginAttempts
threeFailedLoginAttemptsRevokesYourAccount
itShouldNotSetAccountLoggedInIf-
PasswordDoesNotMatch
nonMatchingPasswordDoesNotLogYouIn
itShouldNotRevokeSecondAccountAfterTwo-
FailedAttemptsFirstAccount
failedLoginAttemptsOnOtherAccountsDoes-
NotImpactMyAccount
itShouldNowAllowConcurrentLogins sameUserCannotLoginConcurrently
itShouldThrowExceptionIfAccountNotFound onlyUserWithExistingAccountCanLogin
ItShouldNotBePossibleToLogIntoRevokedAccount userWithRevokedAccountCannotLogin
itShouldResetBackToInitialStateAfter-
SuccessfulLogin
successfulLoginResetsFailedAttemptCount

So why do I prefer calling my test as nonMatchingPasswordDoesNotLogYouIn instead of itShouldSetAccountToLoggedInWhenPasswordMatches?

  • I think the latter is focusing on implementation details versus focusing on the intent.
  • One should write descriptive names, but the longer the name is, that much more difficult it is to read. I want to write my test names such that they are short and concise. Hence I think the whole itShould<> thing seems repetitive without adding much value.

More about my test naming convention here…


    Licensed under
Creative Commons License