Leverage use cases to identify different types of required tests

A top-down approach

Use e2e test to test a use case, an integration test to test a step in a use case, and a unit test to test actions that enable a step.


  1. The user proceeds to checkout.
  2. The user selects one of addresses stored in her account.
  3. The user selects one of her stored credit cards as the payment method.
  4. The user chooses the shipping method.
  5. The user confirms the order.


  1. The above approach naturally associates unit tests to integration tests, integration tests to e2e tests, and e2e tests to use cases. This association can help ensure that we create the tests required to thoroughly test that a system supports the desired use case. Also, the association can help avoid redundant test executions, i.e., execute an integration test only if all of the associated unit tests pass.
  2. The above approach naturally ensures the set of tests associated with a system conforms to a pyramid structure, i.e., test pyramid. For example, in the above example, for happy paths, we will likely end up with one e2e tests, five integration tests, and more than five unit tests.
  3. While the above example focused on the happy path for the sake of brevity, please don’t forget to test sad paths.
  4. I suspect others may have figured out a similar top-down approach to identifying tests from designs. Recently, someone mentioned that the book Growing Object-Oriented Software, Guided by Tests suggests a similar top-down approach to derive tests. So, this book is on my reading list. If you know of other sources describing similar approaches, please share references :)




Software Engineer / Researcher interested in software engineering, programming languages/tools, systems, and data.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

CS371p Spring 2020: Final Entry

Book Recap: High Output Management by Andy Grove

How to Build an API in Python (with Flask & RapidAPI)

Working with web services through ASP.NET Core and DotVVM (A step by step guide)

How To Sell A Football API In 2022

How to make your journey into code much easier: a beginner’s guide to Ruby Enumerables.

Three Developer Articles that Interested Me This Week — 05/23/2022

Outernet with a Grid Antenna & LeanDVB!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Venkatesh-Prasad Ranganath

Venkatesh-Prasad Ranganath

Software Engineer / Researcher interested in software engineering, programming languages/tools, systems, and data.

More from Medium

A Simple Survey on Schemaless Database Storage Design

Three case studies on API-first Development and Consumer-Driven Contracts

Why API Marketplaces Suck

Automating Your Code Quality — Considerations and Innovation