Write Your Test Cases

Identify the Structure of a Test Case.

Test cases are like handing an actor their script.

They provide a detailed description of the steps to follow to test a feature or scenario.

Let’s break down a test case to understand what it’s made of:

  • A Name: It must be descriptive and easy for the test team to understand.

Exemple de nom de cas de test
Example of a test case name.
  • An Identifier: It can be numeric or alphanumeric; the organization defines the naming pattern.

Exemple d'identifiant
Example of an identifier.
  • A Description: This details the test case, including the features or scenarios being tested. The more complete it is, the easier it will be for readers to understand your intention.

Exemple de description
Description Example.
  • Prerequisites: The conditions required to run the test case—system setup, input data, etc.

Example of test prerequisites
Example of Test Prerequisites
  • Test steps: These describe, in sequence, each action to perform and the expected result.

  • This description must be clear, precise, and leave no room for interpretation. Here’s an example of what to prefer and what to avoid:

Preferable

Example of a clear description detailing what to do
Example for a Clear Description

Avoid

Example of a description to clarify
Example of a Description to Be Clarified
  • Each step should validate a single check. Split steps rather than grouping them:

Preferable

Example to follow of a single test step
Example of a Single Test Step

Avoid

Example to avoid of a step containing several steps
Example of a Step Containing Several Steps

  • Notice how each instruction begins with an action verb. This ensures the tester knows exactly what to do.

  • The expected results: They describe how the system should behave after each action. As with steps, keep it to one expected result per step.

Preferable

Exemple d'un résultat attendu unique
Example of a single expected result.

Avoid

Exemple d'un résultat attendu contenant plus d'un résultat
Example of an expected result containing more than one.

Write Your Test Cases.

Now let’s write the test cases in the Test Repository (the area where test cases are stored).

Test cases must correspond directly to the scenarios defined for the project. Return to your list of scenarios and identify the test cases to create.

Here are two examples:

Case 1:

Test case name: Add a product to the shopping cart.

Identifier: PAN-01

Goal: Verify that the user can add a product to the shopping cart.

Prerequisites:

The e-commerce website is accessible.

The user is logged in.

The selected product is available on the website.

Test case:

Step

Action

Expected result

1

Go to the product page the user wants to add

The product page is displayed with all relevant information.

2

Select the desired quantity

The product quantity is updated.

3

Click “Add to cart”

The product is added without error.

4

Check that the product was added

The product is visible in the cart.

5

Open the cart to confirm

The cart displays the added product.

In this example, the steps lack precision. The tester could take a different path than the one you intended, which may prevent them from testing under the correct conditions.

Second case:

Test case name: Add a product to the shopping cart.

Identifier: PAN-01

Goal: Verify that the user can add a product to the shopping cart.

Prerequisites:

The e-commerce website is accessible.

The user is logged in.

The selected product is available.

Test case:

Step

Action

Expected result

1

Access the site via URL xxx

The home page is displayed.

2

Click the Appliances department

The department is displayed.

3

Click the vacuum cleaner image

The product page is displayed.

4

Verify that the product brand is displayed below the product name

The brand yyy is displayed.

5

Select the desired quantity

The quantity updates.

6

Click “Add to cart”

The cart indicator updates.

7

Click the cart pictogram

The cart contents display.

8

Verify that the vacuum cleaner is present

The product is present in the cart.

9

Verify that the quantity matches the value entered in step 5

The quantity is correct.

In this second example, every action is explicit. The tester must follow a precise path, which ensures the intended conditions for validating the Goal.

Update Your Test Cases

During writing, one golden rule applies: be economical.

Don’t reinvent the wheel.

Check your test assets to see whether an existing test case can be updated instead of creating a new one. This prevents clutter and saves significant time.

When updating, pinpoint exactly which steps must change.

Let’s update step 7 of the second case, assuming cart access changes from a pictogram to a hyperlink:

7

Click the “Shopping Cart” hyperlink

The cart contents display.

Over to You!

Context

All requirements have been imported and reviewed.

From your earlier notes, you recall that the following test cases from the test assets must be updated:

  • CDT-2: Place an order as an unauthenticated customer.

  • CDT-3: Place an order as an authenticated customer.

Instructions

Write the new test cases needed for the campaign and update those impacted.

Summary

  • A test case is a sequence of ordered steps guiding the tester toward the scenario Goal.

  • Test cases must make testers autonomous in both understanding and execution.

  • Control the granularity of your steps. Avoid exceeding twenty steps or you risk losing the tester.

  • Reuse existing assets, updating only what is necessary to avoid duplication and save time.

Now that the test cases are written, let’s look at assembling them to build your scenarios.

Et si vous obteniez un diplôme OpenClassrooms ?
  • Formations jusqu’à 100 % financées
  • Date de début flexible
  • Projets professionnalisants
  • Mentorat individuel
Trouvez la formation et le financement faits pour vous