---
title: "Test Naming Conventions With Unit of Work"
url: "https://osherove.com/blog/2012/5/15/test-naming-conventions-with-unit-of-work.md"
canonical: "https://osherove.com/blog/2012/5/15/test-naming-conventions-with-unit-of-work.html"
published: "2012-05-15T16:15:54"
updated: "2012-05-15T16:15:54"
tags: ["Unit Testing"]
author: "Roy Osherove"
description: "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…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Test Naming Conventions With Unit of Work

By Roy Osherove May 15, 2012 In [Unit Testing](https://osherove.com/blog/category/unit-testing)

**Historical article** · Originally published May 15, 2012; technical details may be outdated.

When I name my tests I use the name of the “[unit of work](https://osherove.com/blog/2012/5/15/what-does-the-unit-in-unit-test-mean.html)” 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.

## Lessons on this topic

- [Mapping Moves](https://courses.osherove.com/courses/tdd-pairing-sessions-building-a-go-game/mapping-moves/) · TDD Pairing Sessions - Building a Go Game

## More in Unit Testing

[All posts in Unit Testing](https://osherove.com/blog/category/unit-testing)

- May 16, 2012

    ### [File System Wrappers for Unit Testing in C#](https://osherove.com/blog/2012/5/16/file-system-wrappers-for-unit-testing-in-c.html)

- May 16, 2012

    ### [Test Driven Validation Logic with Extract & Override](https://osherove.com/blog/2012/5/16/test-driven-validation-logic-with-extract-override.html)

- May 15, 2012

    ### [What does the 'unit' in 'unit test' mean?](https://osherove.com/blog/2012/5/15/what-does-the-unit-in-unit-test-mean.html)

- Oct 6, 2011

    ### [Free event and 5 day TDD masterclass in Copenhagen this month](https://osherove.com/blog/2011/10/6/free-event-and-5-day-tdd-masterclass-in-copenhagen-this-mont.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
