Resources
7 min read

How To Write Software Test Cases: A Practical Guide With Examples

Writing clear, specific test cases is the key to reliable results and improved software quality. Here’s everything you need to know to do it well

Wei-Wei Wu
CEO, Momentic
May 8, 2026

Good test cases = reliable test results = better software quality.

It’s easy to understand the basic idea that a set of clear instructions will help with consistency of results, but actually understanding writing software test cases is another thing entirely. You’ll need to understand exactly what you want from your test cases, describe test steps clearly, and ensure repeatability over time.

We’ll start with a quick reminder of what test cases are and their purposes in the testing lifecycle , then jump into our tips on writing software test cases, with a few practical examples to illustrate good practice.

What Are Software Test Cases?

A test case is a set of conditions or variables used to determine whether a particular function in your app behaves as expected.

Each test case is designed to check one specific function or behavior. It gives testers clear instructions on what to test, how to test it, and what the result should be. Here’s a quick example:

Title

Verify ‘add to cart’ button adds object to cart

ps

Navigate to product page

Click ‘add to cart’ button

Navigate to cart

Verify product is in cart

Writing Software Test Cases: What Are The Benefits?

In a nutshell: repeatability, efficiency, and maintained quality.

Without clear test cases, teams often rely on ad-hoc testing, which increases the chance of bugs reaching users.

Keep your approach to writing test cases consistent, on the other hand, and you’ll reduce the risk of missed defects, save time by making tests repeatable, and ensure consistency of execution, which makes results more reliable.

Well-designed test cases also improve communication between testers and developers (with a clear set of instructions, there’s no chance of crossed wires), and provide useful documentation for future releases.

Components of a Test Case

Writing a good test case becomes a whole lot easier if you know exactly what you need to include every time. So, before getting stuck into how to build one, it’s useful to understand what a test case should contain. Here’s a quick-reference overview.

Your Top-Level Test Case Template

FieldDescription
Test Case IDUnique number or code: make sure you’re clear on naming conventions and searchability
TitleName of test case: make sure it’s consistent, unique, and descriptive to avoid duplication
Test scenarioA short description of what is being tested
ModuleWhich feature area is the test in
PriorityHigh, medium, or low, depending on your own priority criteria
PreconditionsAny conditions that must be met before performing the test, e.g., setup criteria
StepsSteps needed to execute the test
Test DataSpecific input values used during testing.
Expected ResultThe outcome that should happen if the software works correctly.
Actual ResultWhat actually happens during execution
StatusPass / Fail

Writing Software Test Cases: Your Step-by-Step Guide

Now, let’s walk through the exact process of how to write software test cases effectively.

Step 1: Understand Your Requirements

Before writing any test case, review the requirements for what you’re testing carefully.

Know what the feature is supposed to do, and who is likely to use it. Understand the business rules that underpin it, and what validations might apply. Finally, be aware of what could go wrong if this feature does not work properly.

For example, if testing a registration form, requirements may state:

  • Email must be unique
  • Password must contain eight characters
  • Required fields cannot be blank

Step 2: Identify Test Scenarios

Test scenarios are high-level areas of a feature that need validation. When testing a particular area, you should build a separate test case for each scenario, each ranked in terms of priority.

So, if you were testing a login page, common test scenarios might include:

  • Successful login
  • Invalid password
  • Blank username field
  • Blank password field
  • Locked account attempt
  • Password reset link functionality

Step 3: Write Clear Test Steps

Each test case should include step-by-step instructions anyone can follow. Good test steps are:

  • Simple
  • Specific
  • Sequential
  • Easy to repeat

Clarity is absolutely key if you want to ensure consistency of execution. Vague instructions like “try logging in” will not give you the results you’re after. A better-written test case example would be:

Open login page

Enter valid email address

Enter valid password

Click Login button

Step 4: Define Your Expected Results

You need to know what should happen when the test steps are executed. For example:

User is redirected to dashboard

Error message displays: “Invalid password”

Submit button remains disabled

Confirmation email is sent

Again, avoid vague results such as ‘Works correctly’. These could mean different things to different people and will not guarantee consistency in pass/fail results.

Step 5: Add Positive and Negative Cases

One common trap that people new to software testing fall into is only creating test cases for ‘happy path’ tests. You test ‘login authorized’ but not ‘login failed’. You should absolutely be testing both sides of the coin.

Positive test cases validate expected user behaviour. For a login page, this would be ‘user logs in with correct credentials’.

Negative test cases validate how your app handles errors. For the login page example, there are, in fact, more negative scenarios than positive. For example:

  • Wrong password entered
  • Empty username field
  • SQL injection attempt in input field
  • Unsupported file upload

Step 6: Prioritize Test Cases

Some test cases are more important than others. High-priority areas are those that affect the everyday functionality of your app the most. To identify these:

  • Look at the features and functions used the most on your app
  • Assess the impact of those features or functions suddenly stopping working

Using these criteria, high-priority test cases usually include login and payment flows, security and data processing , and other core user journeys.

Lower-priority cases may include cosmetic layout issues or rare edge cases.

Step 7: Review and Update Regularly

Your test cases should evolve with your app. Make time to review them regularly, but always after:

  • New feature releases
  • UI changes
  • Requirement updates
  • Bug fixes
  • Workflow changes

Writing Software Test Cases: 2 Examples

Here are two real-world examples of what test cases for a particular function might look like, for two of the most widely tested areas

Login Page Test Cases

Test Case IDScenarioStepsExpected Result
TC_LOGIN_001Valid loginEnter a valid username and password, click loginUser lands on dashboard
TC_LOGIN_002Invalid passwordEnter a valid username and a wrong passwordError message displayed
TC_LOGIN_003Blank usernameLeave username empty, enter passwordValidation message shown
TC_LOGIN_004Blank passwordEnter username, leave password blankValidation message shown
TC_LOGIN_005Remember meTick Remember Me and log inUser remains logged in later


E-commerce Checkout Test Cases

Test Case IDScenarioStepsExpected Result
TC_CHECKOUT_001Add item to cartAdd product and open cartProduct appears in cart
TC_CHECKOUT_002Apply couponEnter valid coupon codeDiscount applied
TC_CHECKOUT_003Invalid couponEnter expired couponError message shown
TC_CHECKOUT_004Successful paymentEnter valid card detailsOrder confirmation shown
TC_CHECKOUT_005Empty addressLeave shipping address blankValidation error shown

Test Cases and Time Burden: What You Need to Know

If you’re working completely manually, creating and maintaining your test cases will be a time burden. That’s not necessarily a bad thing, good test cases are absolutely worth the effort, given the payback they offer.

But, as you scale, you may find that maintenance disproportionately eats into engineering hours. But, what if you could get those engineering hours back with no associate drop in test case quality?

Agentic AI-driven tools like Momentic use a range of methods to help save you time as you build your test suite. For test cases specifically, these include:

  • Natural language test creation: enter a basic test case in plain English and let the software generate the script and run it automatically. Once you’ve got your requirements down, that's a lot of time saved
  • Agentic AI: let your virtual autonomous coworker explore your app independently, analyze high-risk areas and gaps in code, and suggest test cases for your engineers to approve
  • Self-healing tests: cut your maintenance burden with tests that automatically update with UI changes, thanks to reliance on smart, intent-based locators rather than brittle CSS/XPath

Momentic: For Writing Software Test Cases Faster

“Momentic gave us reliable, end-to-end coverage that allows us to focus on feature development instead of maintaining tests”
Alec HoeyAI Engineer, Mutiny

After implementing Momentic, Mutiny saw an 83% decrease in test generation and maintenance times whilst reducing production incidents by 85% across a complex, multi-service product.