Skip to main content
Structure Test Cases

Learn how to structure your test cases most effectively.

Aaron Collier avatar
Written by Aaron Collier
Updated over 9 months ago

General Guidelines

  • Use clear language: simple and clear phases with proper punctuation and capitalization. Make sure to check for grammatical errors (use a spell-checker/Grammarly).

  • If your actions/expected results start getting long, consider breaking them into separate steps.

  • Use basic formatting such as bold and bulleted lists. It presents some distinction during execution. Although the test execution module doesn’t currently display this formatting, once support is added, tests will become easier to read.

  • Don’t use abbreviations that testers aren’t familiar with.

  • Don’t use the word “observe” as a separate action – it’s self-explanatory.

  • Avoid over-specification: The more detailed your descriptions are, the more complicated later maintenance of the test is. Specify only what’s crucial and make sure you are focusing on the app under test, instead of the system/environment functions that aren’t particularly related.

General Examples

Do

Don’t

Ensure your language is clear and concise.

  1. Action: Enter “Super Cola” into product search without hitting “search”.
    Expected Result: Variations of “Super Cola” are displayed as search suggestions.

  2. Action: Select “Super Diet Cola”.
    Expected Result: Product detail page is displayed.

Avoid language errors, abbreviations that aren’t self-explanatory (“sdc”), trivial explanations (it’s self-explanatory that a ‘search’ button is a button), using unusual terms (menu of variations vs. search suggestions), unnecessary use of “observe”.

  1. Action: enter super cola into product serch on the top part of the page and don’t press yet the search btn and observe
    Expected Result: menu of super cola variations appears under search field in

  2. Action: select sdc from the list
    Expected Result: sdc product page with product information opens

Avoid self-explanatory actions that testers should know how to do.

Action: Go offline.
Expected Result: Offline banner is displayed.

  1. Action: Swipe down from the top and turn off WiFi and Mobile data connections
    Expected Result: App is in offline mode

  2. Action: Verify that “Offline” banner is displayed in app
    Expected Result: Offline banner is displayed

Goal

Start the test case with a clear and concise goal, stating the purpose of the test case. Use an info step starting with “The goal of this test is to verify ...” This provides perspective to the tester and/or test case reviewer regarding the specific testing mission.

After completing the test case, make sure to check the test context against the goal. This helps you see whether you covered the initially intended scope.

Goal Examples

Do

Don’t

Include enough context to be clear.

The goal of this test is to cover positive flows for login with just-created and already-existing accounts.

Too generic:

The goal of this test is to test login.

Don’t include too many details to overwhelm.

The goal of this test is to cover a typical purchase scenario starting with product selection and ending with a successful purchase.

Too detailed:

This test covers purchasing functionality, specifically: searching for a product, choosing a quantity of this product, adding additional products to the cart, going to the shopping cart and filling out details, proceeding to the purchase step, and also verifying that the confirmation e-mail arrives.

Prerequisites

  • State any prerequisites required for the test case as a separate info step after the goal.

  • Avoid writing unnecessary prerequisites, assuming that the tester is already onboarded to the particular workspace and has the necessary context.

    • Keep in mind the context to determine if a prerequisite is necessary. For example, a prerequisite to be logged in might not be needed for apps that don't offer any functions to logged-out users, others apps might have logged-out states as an area of a testing focus.

  • Don’t embed another test as a prerequisite.

    • The focus of prerequisites is to ensure a certain state before starting the test case. Asking testers to execute another step as a prerequisite may disrupt the purpose of the test case itself.

    • Testers don't see embedded tests as separate and so they don’t understand that a particular piece is a prerequisite.

    • Instead, state what needs to be achieved. If the journey is complex, include a pathway for how to do it.

Automation and Prerequisites

An underlying principle: If a freelance tester is able to read the test and understand the prerequisites, it should also apply to a QE who is scripting the test case. Don't add prerequisites just for automation context.

This applies even with complex scenarios where a particular test case can only be executed once a certain state of the system is reached. The prerequisite description should be enough to understand how to reach the particular state. The QE then chooses an appropriate method to the prerequisites (such as interacting directly with APIs to generate data in advance).

Prerequisite Examples

Do

Don’t

Leave out unnecessary prerequisites.

Avoid self-explanatory situations, such as this for a new account registration test:

User is not logged in

Skip over details of getting to the prerequisite:

Prerequisite:
User has added a product to the cart.

Note: If it’s not self-explanatory how to get to the prerequisite state (for example, if you need some unusual steps to get a product in the cart), then write out the step sequence without verification actions. The goal is only get to the required state.

Avoid embedded tests with detailed steps:

  1. Action: Enter “Super Cola” into the product search
    Expected Result: 6 variations of Super Cola are displayed

  2. Action: Select “Super Diet Cola” and verify that top banner changed
    Expected Result: Top banner has changed to “Healthy choice - Zero Calories”

  3. Action: Add Super Diet Cola to the cart
    Expected Result:
    * Cart counter is updated to indicate added product.
    * Product appeared in the cart list.

Test Flow

  • Begin the flow of test steps after any prerequisites.

  • Ensure that testers can follow the test flow without having to go back to previous steps. Returning to previous steps and re-executing them disrupts the tester’s workflow and hinders the ability to later determine which steps actually passed and failed based on which conditions.

  • If certain steps need to be done more than once, create an embedded test to handle those steps.

Test Flow Examples

Do

Don’t

For short sequences, repeat the steps in the test case.

  1. Action: Enter “Super Cola” into the product search.
    Expected Result: 6 variations of Super Cola are displayed

  2. Action: Select “Super Diet Cola”.
    Expected Result: Top banner has changed to “Healthy choice – Zero calories”.

  3. Action: Add Super Diet Cola to your cart.
    Expected Result:
    * Cart counter is updated to indicate added product.
    * Product appeared in the cart.

  4. Action: Select “Super Sugar Cola”.
    Expected Result: Top banner has changed to “Good choice – Sugar rush guaranteed”.

  5. Action: Add Super Sugar Cola to your cart.
    Expected Result:
    * Cart counter is updated to indicate added product.
    * Both products are properly in the cart.

Don’t ask tester to redo specific steps:

  1. Action: Enter “Super Cola” into the product search.
    Expected Result: 6 variations of Super Cola are displayed.

  2. Action: Select “Super Diet Cola”.
    Expected Result: Top banner has changed to “Healthy choice – Zero calories”

  3. Action: Add Super Diet Cola to your cart.
    Expected Result:
    * Cart counter is updated to indicate added product.
    * Product appeared in the cart.

  4. Action: Repeat steps 2-3 for “Super Sugar Cola”.
    Expected Result: Top banner changed to “Good choice – Sugar rush guaranteed” and product is in the cart.

Unless a certain scenario is targeted on its own, make sure that steps progress logically so that testers don’t need to spend extra time repeating actions.

  1. Action: Verity that for empty cart, a placeholder message is displayed.
    Expected Result: Placeholder “No items in cart” is present.

  2. Action: Add product to the cart.
    Expected Result: Product is in the cart; cart counter has been updated.

OR (combining with an extra verification):

  1. Action: Add product to the cart.
    Expected Result: Product is in the cart; cart counter has been updated.

  2. Action: Remove the product from the cart.
    Expected Result: Product is removed, cart counter is updated to zero.

  3. Action: Verity that for an empty cart, a placeholder message is displayed.
    Expected Result: Placeholder “No items in cart” is present.

Don’t place steps in a random order that forces testers to take extra actions to complete tasks.

  1. Action: Add product to the cart.
    Expected Result: Product is in the cart; cart counter has been updated.

  2. Action: Verity that for empty cart, a placeholder message is displayed.
    Expected Result: Placeholder “No items in cart” is present.

Info Steps

  • Use Info Steps to state the purpose of the test case, describe prerequisites, or provide additional context for the test case or upcoming steps.

  • For longer or complex descriptions, consider attaching videos or screenshots to effectively deliver the message.

  • Structure and outline the information in a clear and organized manner.

  • When considering giving the full details of a story/epic to a tester, consider the following:

    • Is the information relevant to testers (or is it, for example, internal client notes)? If it’s not relevant, remove it.

    • Will this information be used by multiple testers (such as when test cases where this is included are executed multiple times)? If yes, consider summarizing the content to reduce the total time spent by testers. For one-time tests, it might be more expensive (in client services time) to summarize than to provide the input directly to testers.

  • Never use Info Steps for verification. While Info Steps can draw attention to certain areas of the product, if you want testers to validate a function, you need to add a clear pass/fail step for that to the test.

Info Step Examples

Do

Don’t

Include only what testers need for testing.

The main changes for the Shopping Cart feature are:

Cart View Enhancement:

  • Improved layout for clear item viewing.

  • Quantity adjustments within the cart.

  • One-click item removal.

Save for Later:

  • The ability to save items for future purchase.

  • Easy transition of items between cart and "Save for Later".

See attached screenshots.

Don’t include epic information with internal notes that aren’t relevant. The content in the Do column is also shorter, but you can shorten the text with AI once it becomes available to keep it cost effective.

Here’s an outtake of the user story for your context:

This epic entails a comprehensive set of improvements to our existing Shopping Cart functionality, aiming to streamline the purchasing process, increase customer satisfaction, and lay the foundation for future enhancements.

  • The Product team discussed potential UX improvements during the last sprint review.

  • John highlighted the urgency of optimizing cart abandonment rates due to the current market.

  • The backend team provided API documentation for inventory synchronization.

User Stories:

  1. As a customer, I want to easily view and manage items in my cart:

    • Break down the existing cart view into a clean and intuitive layout.

    • Implement a quantity adjustment feature within the cart.

    • Allow customers to remove items from the cart with a single click.

  2. As a customer, I want the option to save my cart for later:

    • Develop a "Save for Later" functionality that moves items from the cart to a separate list.

    • Enable customers to easily move items back to the cart from the "Save for Later" list.

Present context with clear structure for easy understanding.

Here are user stories reflecting the main changes in the functionality under test:

  1. As a customer, I want to easily view and manage items in my cart:

    • Break down the existing cart view into a clean and intuitive layout.

    • Implement a quantity adjustment feature within the cart.

    • Allow customers to remove items from the cart with a single click.

  2. As a customer, I want the option to save my cart for later:

    • Develop a "Save for Later" functionality that moves items from the cart to a separate list.

    • Enable customers to easily move items back to the cart from the "Save for Later" list.

Avoid putting all the text into one unstructured blurb in an info step.

User Stories:

As a customer, I want to easily view and manage items in my cart. Break down the existing cart view into a clean and intuitive layout. Implement a quantity adjustment feature within the cart. Allow customers to remove items from the cart with a single click.

As a customer, I want the option to save my cart for later. Develop a “Save for Later” functionality that moves items from the cart to a separate list. Enable customers to easily move items back to the cart from the Save for Later list.

Pass/Fail Steps

  • Each test step should consist of one logical action and one logical verification.

  • Use clear assertive language in the action step, such as “Do X” or “Do Y”.

  • The logical verification is the expected result, which should be the outcome of the performed action.

    • Please note that stating that the user has to "verify that Function X works” is not helpful for either testers or QEs automating the test. You need specify what "works" means and state the specific expected result.

  • If the expected result requires additional actions for verification, include them as separate steps.

  • If there are multiple items to pay attention to in the expected result but you still want to group them in a single verification to more easily maintain the test case, then clearly separate the items using a bulleted list for traceability.

    • Use this approach with caution – when one expected result has multiple verifications, testers often miss the extra verifications. A good example where such an option could be used: the user needs to verify that a menu contains specific items – all of these items are listed.

  • Avoid writing unnecessary expected results and consider combining actions if the expected result is trivial.

  • It's acceptable to treat a step as a pathway to the final outcome of a complex flow.

Step Detail for Automation

For automation, there is no need to over-specify the flow or details of a step as long as the action and expected results are clear. Do not create maintenance overhead.

For example, if the test case is about setting a date in a calendar, then it is enough to ask the user to select a date from the calendar instead of guiding them to click the top right corner, select the calendar menu item, verify that the calendar opens, and so on. That context should be self-explanatory for testers and any QEs who understand the product and the test goal.

Pass/Fail Step Examples

Do

Don’t

Include additional actions as separate steps or, when appropriate, as a separate test.

  1. Action: Add an item to your cart.
    Expected Result: Cart counter is updated.

  2. Action: Add multiple items to the cart.

    Expected Result: Cart counter is updated accordingly.

  3. Action: Remove item from the cart.
    Expected Result:
    * Item is removed from the cart.
    * Cart counter is updated.

  4. Action: Remove all items from the cart so that it is empty.
    Expected Result: A “No items in the cart” message is displayed.

A separate test for removing items from a past shopping session.

Don’t include further actions in the expected result.

  1. Action: Add item to a cart.
    Expected Result: Cart counter is updated. Make sure to also test for adding multiple items to the cart.

  2. Action: Remove item from the cart.
    Expected Result: Item is removed from the cart. Once cart is empty, a “no items in the cart” message is displayed. Note: make sure to also cover the scenario where you resume a shopping session that has items in the cart and then remove them.

Clearly define what is an action and what is a prerequisite or expected result.

  1. Info step: Prerequisite: User is signed in as an admin user.

  2. Action: Click on hamburger menu → Act as another user → Select the user.
    Expected Result: Other user is selected and an “Acting as another user” message should appear in green.

Don’t confuse actions with prerequisites or include actions in expected results.

  1. Action: Sign in as an admin user.
    Expected Result:
    * Click on hamburger menu → Act as another user → Select the user.
    * User should be able to select user from the list and an “Acting as another user” message should appear in green.

Cover multiple verifications with separate test steps or potentially split into separate test cases. For example, verify the presence of fields with clear actions about those fields:

  1. Action: Click “New issue”.
    Expected Result: New issue adding screen is displayed.

  2. Action: Verify maximum length of the Title field.
    Expected Result: Field accepts up to 300 characters.

  3. Action: Verify maximum length of the Description field.
    Expected Result: Field accepts up to 1,000 characters.

  4. Action: Verify that you can select a priority.
    Expected Result: High/Medium/Low/Nice to have options are present and priority can be selected.
    <…Continuing in a similar style with clear verification of fields. Tag selection and attachment uploading are covered in depth in another test…>

Don’t include too many verifications in one expected result.

  1. Action: Click “New issue”
    Expected Result: New issue adding screen appears with the following fields:
    * Title text field.
    * Description text field.
    * Priority menu: High/Medium/Low/Nice to have.
    * Severity menu: High/Medium/Low.
    * Tags: An autocomplete field with a default text of “+Add”. User can add multiple tags and remove tags by clicking them.
    * Environment: A dropdown select with “QA” and “Dev” as options.
    * Attachments: A “Browse” button that opens a system dialog to select files; user must be able to select any attachment.

Test Case Duration

Aim for targeted execution and reusability by keeping the execution time within specific limits:

  • Function-based test cases should not exceed 5 minutes.

  • Scenario-based test cases should not exceed 10 minutes.

  • As a general rule, limit the number of steps in a single test case to no more than 15.

In certain scenarios, it might not be possible to achieve these targets because of the specifics of the function under test (such as complicated actions or waiting time). Still, it’s easier to estimate a shorter test than a longer one.

Test Case Data

Instead of hardcoding test data, provide context to the tester on what is considered relevant or irrelevant data and how to obtain it.

If a customer requires exact reporting on the data used, consider adding a short-answer or paragraph step after a pass/fail step asking the tester to list the data used.

Test Case Data Examples

Do

Don’t

Describe what's necessary from the perspective of the function.

Action: Verify that the start date field accepts only upcoming dates, inclusive of the ongoing day.
Expected result: User is able to enter only the dates starting from the current day. Input of past dates is restricted.

Avoid specifying information that isn't relevant to the function itself.

  1. Action: Try to enter yesterday to the start date field
    Expected result: Input of past dates is restricted.

  2. Action: Try to enter a date of a year ago to the start date field
    Expected result: Input of past dates is restricted.

  3. Action: Enter today to the start date field
    Expected result: Date is accepted

  4. Action: Enter some date from next month to the start date field
    Expected result: Date is accepted

Prerequisite: There are at least two products that are in-stock and at least two products that are out of stock.
Note: You can get a full list of products currently in stock from Admin → Product management → Products → Apply the ‘In stock’ filter.


Action: Verify that the product dropdown shows only in-stock products.
Expected result: Only products currently available are displayed in the dropdown. Out-of-stock products are not shown.

  1. Prerequisite: "Super Cola" and "Super Diet Cola" are in stock. "Super Zero Cola" is out of stock.

  2. Action: Verify that "Super Cola" is present in the product dropdown.
    Expected result: "Super Cola" is present in the producs dropdown.

  3. Action: Verify that "Super Diet Cola" is present in the product dropdown.
    Expected result: "Super Diet Cola" is present in the product dropdown.

  4. Action: Verify that "Super Zero Cola" is not present in the product dropdown.
    Expected result: "Super Zero Cola" is not present in the product dropdown.

What's Next

Did this answer your question?