The Difference Between Use Cases and Test Cases

praying mantis

People who are new to software, requirements, or testing often ask “What’s the difference between a use case and a test case?” This article answers that question, by building on earlier articles about use cases and use case scenarios. At the soundbite level, each use case has one or more scenarios, and each use case scenario would lead to the creation of one or more test cases.

Definition of a Use Case

flow chart of a use case

Use cases tell the story of how someone interacts with a software system to achieve a goal. A good use case will describe the interactions that lead to either achieving or abandoning the goal. The use case will describe multiple paths that the user can follow within the use case.

Definition of a Use Case Scenario

diagram of a use case diagram of a use case scenario

A use case is made up of one or more use case scenarios. Each path that can be followed within the use case is a use case scenario. Any given example of following a use case also follows a single scenario. Multiple executions of the use case can use the same or different scenarios.

Definition of a Test Case

There are many different kinds of testing, and they can be described in different ways. They can be done by different people to achieve different objectives. They can be manual or automated. Testing is a very large field, and this article is not trying to define all of the ways that people can test software.

When someone asks the question “What’s the difference between a use case and a test case?” they are generally referring to system tests, “end to end” tests, or blackbox tests. They are probably not thinking about unit tests or integration tests.

Check out this explanation of the difference between unit tests and system tests. Or this article for an introduction to Continuous Integration – an approach to test automation and software development, or this article on the essential practices of continuous integration.
System Test Cases

Many system tests are designed to simulate how a user interacts with the system, to make sure that the system responds appropriately. If you’ve defined your requirements by using goal driven use cases, you can use the use cases as a framework for defining these test cases.

These system tests should be created to test a single situation. When using the approach of use cases and use case scenarios to describe requirements, a system test should test a single use case scenario.

In an example use case we recently wrote, one alternate flow “3A1” involves the user entering shipping and billing information that is unique to the order they are placing. You would define at least one use case scenario that involves these steps. Assume that the scenario you have defined follows alternate flow “3A1” but otherwise follows the normal flow.

use case scenario selected

You could create two system tests that are designed to validate that the requirements of the use case are met. The first system test would involve a user that has an account but elects to use different information for this order. This is a realistic scenario – perhaps someone is ordering a gift to be delivered to their cousin who lives at a different address.

You could also define a system test that involves a user without a pre-existing account.

Both test cases follow the use case, and both test cases follow the use case scenario. But the test cases test different things (from a business / requirements perspective). They may be testing exactly the same code, but from a system test perspective, you neither know nor care because a system test is a blackbox test.

Summary

A use case represents the interactions (or observed behaviors) associated with achieving or abandoning a goal. A use case scenario represents one of the possible paths through a use case. A test case represents one set of inputs that exercises a single use case scenario.

  • Scott Sehlhorst

    Scott Sehlhorst is a product management and strategy consultant with over 30 years of experience in engineering, software development, and business. Scott founded Tyner Blain in 2005 to focus on helping companies, teams, and product managers build better products. Follow him on LinkedIn, and connect to see how Scott can help your organization.

3 thoughts on “The Difference Between Use Cases and Test Cases

  1. Hi,
    This is a great simple explanation of the difference between use cases and test cases. It would be helpful to read some every day life customer examples.
    Thanks for the good work!
    H. Assous

  2. Pingback: Rudi Victor

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.