A Guide to Writing Effective Test Cases

Aycan Aydın
6 min readMar 20, 2024

--

In Software Development Life Cycle (SDLC) or Agile Software Development, conducting comprehensive and detailed testing after the development of software products is a crucial part of the process. In order to perform an effective testing, it is essential to plan and write test cases that can determine whether the software validates the expected requirements.

In this context, defining the test case should be considered as the first step.

What Is a Test Case? A test case is a set of steps that will determine whether a system being tested meets its requirements as expected. Test case writing is one of the fundamental stages in test planning and execution activities.

Test cases can be written using tools such as Excel spreadsheets or a test management tool. Regardless of the method used, some considerations are essential for effectively writing a test case:

1. Understand the Scope and Requirements: Before starting to write a test case, ensure a clear understanding of the scope and requirements. If there are any unresolved or ambiguous issues within the requirements, address them.

2. User-Centric Perspective: When creating test cases, keep the end user’s perspective in mind. Evaluate how the user experience should become from an end-user point of view. Consider how the application can be used most easily, effectively, and efficiently. Think about situations where the end-user might commonly encounter errors.

3. Keep It Simple and Specific: Write test cases that align with the requirements and keep them as simple, specific, and modular as possible. List scenarios related to specific requirements under main headings and create a separate test case for each one of them.

4. Clear for Everyone: When creating a test case, it is essential that the test case is clear not only to the test engineer who writes it but also to anyone reading the test case. Make sure that your instructions are clear and easy to follow, so that even someone who has not previously performed the relevant test can execute the test.

5. Details matter: Describe the test steps clearly and concisely within the test case. A test case should include test steps relevant to the functions within the test scope. For example, if you need to create a bank customer using either an ID number or a passport ID, you can write two different test cases:

  • Add a customer with an ID number.
  • Add a customer with a passport number.

Listing all alternatives within a single test can complicate the test case, making test execution and bug tracking more difficult.

6. Traceability: Ensure that your test case is traceable to all requirements. You can create a Requirement Traceability Matrix (RTM) and match each requirement to a specific test case. Alternatively, in agile/waterfall processes, you can link relevant stories, bugs, or tasks to test cases using tools like Jira or other test management tools.

Figure 1-A Simple RTM Example
Figure 1-A Simple RTM Example
Figure 2-Linking test case with a story

7. Reusable Test Cases: Strive to establish a standard when writing test cases. Writing reusable test cases or importing common test steps can be beneficial. Using a test management tool can be really a lifesaver and time-saving test management strategy when used to reuse test steps. So, try to avoid duplicating test cases for running the same test under identical conditions or testing with different data.

Figure 3-An Xray Example for Importing Steps and Calling Tests

8. Expected Results Definition: Clearly state the expected results to be used in test execution process.

9. Test Coverage: When writing a test case, cover positive and negative scenarios, boundary conditions, edge cases, and all expected states. Creating separate test cases for the happy path and alternative flows contributes to an effective testing process.

10. Helpful Testing Techniques: When creating test cases, you can leverage various test techniques. Below are some commonly used black-box testing techniques:

a. Boundary Value Analysis (BVA) involves testing the boundary values of an input.

b. Equivalence Partition (EP) focuses on testing values within the same range, assuming they should yield the same result.

c. State Transition Technique tests the expected behavior during transitions between specific states in a system.

11. Data Selection: When writing test cases, select data that is applicable in real-world scenarios. Otherwise, the test scenario may yield inaccurate results.

12. Preconditions: Attempt to define preconditions before starting the test if required for test case. For example, in order to grant commercial credit to a corporate customer, create a precondition that a “corporate” customer must have already been created before.

13.Datasets can be helpful: Some testing tools allow you to create an iterative structure for test cases when necessary. For instance, if you need to test different outcomes based on a set of values, you can use datasets and parameter features to create test cases.

Remember that you don’t necessarily need a specialized test management tool; you can achieve this by creating an Excel dataset as well.

Figure 4-Creating a dataset for password validation test case

14. Use Labels, stay organized: When creating test cases, consider using labels to organize them effectively. For instance:

o UI Tests

o Integration Tests

o Performance Tests

o Workflow-Specific Tests

o Application-Specific Tests

15. Add Attachments for Detailed Explanation: To provide more detailed context within a test case, consider preparing and adding attachments. These attachments can enhance understanding both the workflow and the testing process. Attachments may include different file types such as Word Documents, Excel Files, Videos, Images etc.

16. Maintenance and Keeping Test Cases Up-to-Date are significant:

o Review and update test cases to ensure their relevance regularly.

o When creating a new test case, identify related test cases and maintain consistency across them.

o Remove unused or obsolete test cases, especially if the process has significantly changed.

Remember: A well-organized and up-to-date test case contribute to a robust and cohesive testing structure.

17. The power of test automation: When writing test cases, consider automating repetitive and time-consuming test cases. Determine whether the relevant test case should be a part of the test automation process. If so, establish related automation tasks, bridging between manual and automated testing. Utilizing a test management tool streamlines this process, making it easy to track, monitor, and report.

In our company, we use the “To Be Automated” field in Jira for this purpose. After completing a test case and performs tests, if QAs consider that the test case should be automated, then they mark this field as “Yes” and proceed it into the automation planning process. This way, we establish a link between manual and automated testing.

Figure 5-Planning a test case for automation planning

18. Stay in touch with colleagues: While creating test cases, consider having your team members review them when required. This mutual exchange improves the maturity of test case creation and enables continuous enhancement of cases.

Maintaining consistency and standardization across test cases enhances readability and facilitates test execution. For instance, when defining test cases for a screen, if CRUD (Create, Delete, Read, Update) scenarios exist, then creating standardized test cases for all pages in the product with this feature simplifies our work. Creating separate test cases for the scenarios except these standard features allows us to focus more on writing non-standard test cases in a limited time.

As a conclusion, it is obvious that writing well-designed test cases is the key to a successful testing process. The quality of your written cases directly impacts the quality and success of the software. Utilizing a test management tool contributes to the effective execution of test processes.

Aycan Aydın

--

--