Turning a Requirement into Test Cases
Writing test cases is not simply about converting requirements into a list of steps. A good test case starts with understanding what the system is supposed to do, identifying the rules behind the requirement, and deciding what needs to be verified.
For beginners, one of the hardest parts is often knowing where to start.
Let's walk through a practical example using a fictional online shopping cart. We will take one business requirement and turn it into six test cases, including test data, expected results and a simple requirements traceability matrix.
1. Start with the requirement
Imagine receiving the following requirement:
REQ-CART-01 – Changing product quantity in the shopping cart
A user can set the quantity of a product in the shopping cart to an integer between 1 and 10, inclusive. Once a valid quantity is accepted, the system recalculates the line subtotal as unit price multiplied by quantity. Values outside the 1–10 range and non-integer values must not be accepted.
It looks straightforward. The user changes the quantity, and the system updates the price.
But before opening the application, ask yourself:
- What is the minimum allowed quantity?
- What is the maximum allowed quantity?
- Can the user enter zero?
- What happens when a negative number is entered?
- Are decimal values accepted?
- Is the line subtotal recalculated correctly?
This is where test analysis begins.
2. Break the requirement into test conditions
One requirement can contain several independent business rules.
In our example, we can identify three test conditions:
| ID | Test condition |
|---|---|
| RQ-01 | Quantity must be between 1 and 10, inclusive |
| RQ-02 | Quantity must be an integer |
| RQ-03 | Line subtotal must equal unit price multiplied by quantity |
Why separate them?
Because one test case does not necessarily need to verify everything at once.
Combining multiple objectives in one test makes it harder to identify the cause of a failure.
Separating conditions also helps us check whether all important parts of the requirement have been covered.
3. Identify ambiguities before writing tests
Requirements are not always complete.
Our example says that invalid values must not be accepted. However, it does not explain:
- Should the field restore the previous value?
- Should an error message appear?
- Should validation happen immediately or after confirmation?
- Should the invalid value remain visible in the field?
These are important questions.
A tester should not invent application behaviour just because it seems logical.
If the requirement does not specify the exact validation response, ask the Business Analyst or Product Owner for clarification.
You can test what is explicitly defined, but your assumptions should never silently become official requirements.
4. Choose appropriate test design techniques
You do not need to test every possible input value.
This is why test design techniques are useful.
Two particularly relevant techniques are Equivalence Partitioning and Boundary Value Analysis.
Equivalence Partitioning
Equivalence Partitioning divides input data into groups expected to behave similarly.
For our requirement, we can identify four distinct partitions:
| Partition | Example data | Expected behaviour |
|---|---|---|
| Valid integer | 1–10 | Accepted |
| Integer below minimum | 0 or less | Rejected |
| Integer above maximum | 11 or more | Rejected |
| Non-integer numeric value | 2.5 | Rejected |
Instead of checking every possible value, we select representative values from each partition.
This reduces unnecessary testing while maintaining meaningful coverage.
Boundary Value Analysis
Defects frequently occur around boundaries, so values close to the limits deserve special attention.
For the allowed range of 1–10, two-value Boundary Value Analysis gives us:
- 0 – immediately below the minimum;
- 1 – minimum allowed value;
- 10 – maximum allowed value;
- 11 – immediately above the maximum.
With three-value Boundary Value Analysis, we would additionally check the values immediately inside the boundaries: 2 and 9.
These techniques help us select tests with a clear purpose rather than randomly entering numbers into a field.
5. Design the test cases
Let's move to the practical part.
Assume that a product in our fictional online store costs $19.99.
To keep the example focused, we will exclude taxes, discounts and delivery charges. We only want to verify the product line subtotal.
Based on the requirement, we can prepare six test cases:
| ID | Test data | Test objective | Expected result |
|---|---|---|---|
| TC-01 | 1 | Minimum boundary | Quantity accepted, subtotal $19.99 |
| TC-02 | 3 | Typical valid quantity | Quantity accepted, subtotal $59.97 |
| TC-03 | 10 | Maximum boundary | Quantity accepted, subtotal $199.90 |
| TC-04 | 0 | Below minimum | Value not accepted |
| TC-05 | 11 | Above maximum | Value not accepted |
| TC-06 | 2.5 | Non-integer value | Value not accepted |
Notice something important: the requirement tells us that invalid values must be rejected, but it does not define the exact error message or how the field should behave.
We should not invent those details.
A complete test case example
A table containing test data and expected results is useful, but a complete test case usually contains more information.
Let's expand TC-02.
Test Case ID: TC-02
Title: Verify that the cart accepts a valid product quantity.
Requirement: REQ-CART-01
Preconditions:
- A product is present in the shopping cart.
- The product unit price is $19.99.
- The current product quantity is 2.
- No discounts have been applied.
Test Data:
- New quantity: 3.
Test Steps:
- Open the shopping cart.
- Locate the product whose quantity you want to change.
- Change the quantity from 2 to 3.
- Confirm the change if required by the application.
- Check the product quantity and line subtotal.
Expected Result:
- The system accepts a quantity of 3.
- The product quantity in the cart is 3.
- The line subtotal is recalculated to $59.97.
Actual Result: Not run.
Status: Not run.
Why use Not run?
Because designing a test case does not mean that the test has been executed.
Only after running the test can we compare the actual application behaviour with the expected result.
If both match, the test can receive PASS. If they differ, it can receive FAIL and require further investigation.
This distinction is important in professional test documentation.
6. Check requirement coverage
After designing your test cases, return to the original requirement.
Ask yourself:
Does every important part of the requirement have at least one corresponding test?
Our simple traceability matrix could look like this:
| Requirement condition | Test cases |
|---|---|
| RQ-01: Quantity between 1 and 10 | TC-01, TC-02, TC-03, TC-04, TC-05 |
| RQ-02: Quantity must be an integer | TC-01, TC-02, TC-03, TC-06 |
| RQ-03: Correct line subtotal calculation | TC-01, TC-02, TC-03 |
This is a basic Requirements Traceability Matrix.
It helps us identify missing conditions, reduce unnecessary duplication and understand why each test case exists.
However, requirement coverage does not automatically mean that the entire functionality has been tested. Integrations, risks and additional behaviours may require further testing.
7. Common mistakes when writing test cases
Here are six mistakes beginners should watch out for.
1. Writing steps without defining the expected result
"Click the button and check whether it works" does not explain what should actually happen.
2. Combining too many objectives into one test
If a single test checks quantity, discounts, delivery and payment simultaneously, identifying the cause of a failure becomes difficult.
3. Ignoring negative scenarios
Testing only valid input is not enough. Invalid input is equally important.
4. Treating assumptions as requirements
If the documentation does not define a particular behaviour, do not present your own interpretation as the expected result.
5. Not linking test cases to requirements
Without a requirement identifier, it becomes harder to understand why a test exists and which condition it verifies.
6. Treating a designed test as an executed test
A test case may be ready, but until it has actually been executed, there is no basis for assigning PASS or FAIL.
8. From requirement to test case: the complete workflow
Writing test cases is primarily a process of structured reasoning.
A good tester does not start by randomly clicking through an application.
The process starts with understanding the requirement, identifying test conditions, selecting appropriate data and defining expected results.
A practical workflow looks like this:
- Read and understand the requirement.
- Break it into smaller, testable conditions.
- Identify ambiguities and missing information.
- Select appropriate test design techniques.
- Define test data, steps and expected results.
- Review requirement coverage.
- Execute the tests and record actual results.
The goal is not to write as many test cases as possible.
The goal is to make every test meaningful, repeatable and connected to a specific requirement.
Good test cases begin with good analysis – long before the first click.
Disclosure: AI tools were used to assist with drafting and language editing of this article. The author is responsible for reviewing and verifying the technical content and examples before publication.
Top comments (0)