Based in Sydney, Australia, Foundry is a blog by Rebecca Thao. Her posts explore modern architecture through photos and quotes by influential architects, engineers, and artists.

Test Naming Conventions With Unit of Work

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.

Zen of python revisited with code samples

What does the 'unit' in 'unit test' mean?