Test Naming Conventions With Unit of Work
Tuesday, May 15, 2012 at 7:15PM
Roy Osherove in Unit Testing

When I name my tests I use the name of the “unit of work” as the first part. If the unit of work is bigger than a method, I usually name the test with the name of the initial public method that starts the unit of work. 

Test names are affected by the type of end result we are expecting. So a test might look like this for a return value result:

IsLoginOK_UserDoesNotExist_ReturnsFalse

or like this for a state change result:

AddUser_ValidUserDetails_UserCanBeLoggedIn

or like this for 3rd party end results (when we use mock objects):

IsLoginOK_LoginFails_CallsLogger

 

the first part is the unit of work. the second part is the scenario. the third part is the expected end result or behavior of the system.

Article originally appeared on Osherove (http://osherove.com/).
See website for complete article licensing information.