How to Write Test Cases: A Step-by-Step QA Guide

Written by Coursera Staff • Updated on

Learn about the different types of test cases and how to write them in this 2023 guide.

[Featured image]  Quality assurance test case writer demonstrates test case examples on a grid of four wall-mounted monitors.

Test cases are designed to verify that your application is operating as expected. Test case writers design test cases so testers can determine whether an app or software system's feature is working correctly. Applications must be tested thoroughly to find out how the system behaves under all possible input conditions. A clear understanding of software functions and the testing process can make writing tests that identify defects easier. You can use the following walkthrough to learn more about writing and formatting different types of test cases.

What is a QA test case?

Test cases are instructions for testers to follow to ensure programs are functioning properly. They describe how the software should work in normal, abnormal, or error operating conditions. Test case writing converts user requirements into a set of test conditions and descriptions that indicate how a system is functioning. In an automated test script, more than one test case can combine to form a test suite.

If you're practicing your test case writing skills to advance your career, you might consider earning a credential to demonstrate your efforts. For example, you can earn a certificate in Software Testing and Validation from the University of Leeds in just five hours. Or, put some practical experience on your resume by creating your first test automation script using Selenium and Java. You'll be guided through the process and complete a project for your portfolio in just two hours with the following Guided Project:

Test case vs. test scenario 

When writing a test case, you typically think about every detail of "how" something should behave. For example, if you’re developing a login system, a test case might be that an error is displayed if you enter an incorrect email address. Then you may have tests for:

  • Not entering any email address

  • Adding a space at the end of an email address

  • Use all caps for the email address

  • Capitalizing the first letter of the email address

Test scenarios, also called test conditions or test possibilities, represent typical tasks users might want to accomplish with the software. A simple test scenario may require multiple test cases to cover the different outcomes. In our login system, some scenarios could be "I can successfully log in" or "I can't log in without entering my email address correctly."

TIP: Sometimes, the terms test case and test scenario seem interchangeable—but it's helpful to remember that "scenario" refers to the bigger picture of what you're trying to accomplish with your tests, and a "test case" focuses on the minute details of the test scenario. 

Placeholder

Types of test cases 

Test cases can be categorized based on the purpose they serve in testing. As a quality assurance professional, knowing the difference between them helps focus your efforts and choose the right test format. 

  • Functionality test cases: These are the most basic and obvious test cases to write. They ensure that each feature of your system works correctly. 

  • Performance test case: This test ensures that the system runs fast enough. It makes sure that all system requirements work as expected regarding speed, scalability, or stability.  

  • Unit test cases: Software developers usually write unit tests for their code to check individual units, for example, modules, procedures, or functions, to determine if they work as expected. 

  • User interface (UI) test cases: It’s important to remember that the user interface is part of the overall system and not just a shell where functionality appears. UI test cases check that each UI element works correctly, displays, and is easy to use. 

  • Security test cases: Security test cases help ensure that a product or system functions properly under all conditions, including when malicious users attempt to gain unauthorized access or damage the system. These test cases safeguard the security, privacy, and confidentiality of data.

  • Integration test cases: These ensure that the application components work together as expected. These test cases check whether modules or components integrate seamlessly to form a complete product.

  • Database test cases: These test cases ensure that the database meets its functional and non-functional requirements. They make sure database management systems (DBMS) support all business requirements.

  • Usability test cases: Usability test cases help check if users can use the application successfully. These determine whether users can easily use the system without difficulty or confusion. They also verify if users can navigate the system using common procedures and functions.

  • User acceptance test cases: User acceptance test cases verify that an application satisfies its business requirements before users accept it. These determine whether users accept or reject the output produced by a particular system before release to the live environment.

  • Regression testing: Regression test cases verify that changes made during development don’t cause any existing functionality to stop working. Regression testing happens after changes have been made to existing code to test that all existing or legacy functionality continues to work as expected after making the changes.

Coursera Plus
Build job-ready skills with a Coursera Plus subscription
  • Get access to 10,000+ learning programs from world-class universities and companies, including Google, Yale, Salesforce, and more
  • Try different courses and find your best fit at no additional cost
  • Earn certificates for learning programs you complete
  • A subscription price of $59/month, cancel anytime

Who writes test cases? 

Writing test cases is normally the responsibility of someone on the software development team, testing team, or quality assurance team. It’s typically preferred that a professional who was not involved with writing the code should write the test cases since they have a fresh perspective. Different software development frameworks like Agile and Scrum may vary in their QA testing approaches.

Read more: Agile vs. Scrum: How to Choose the Best Method

How to write test cases: A step-by-step guide

Test cases are the blueprints that testers will follow, so they must be clear, thorough, and accurate. Below, we've outlined 10 steps you can take whether you're writing new test cases or revisiting and evaluating existing test cases.

  1. Define the area you want to cover from the test scenario.

  2. Ensure the test case is easy for testers to understand and execute.

  3. Understand and apply relevant test designs.

  4. Use a unique test case ID.

  5. Use the requirements traceability matrix in testing for visibility.

  6. Include a clear description in each test.

  7. Add proper preconditions and postconditions.

  8. Specify the exact expected result. 

  9. Utilize suitable testing techniques. 

  10. Get your test plan peer-reviewed before moving forward.

Best practices for well-written test cases

You can use the tips in this section with the list above to create an efficient but thorough workflow. Let's start with two quick tips:

  • Make test cases reusable and maintainable wherever possible. Your needs will vary depending on the software, application, or specific features you're testing. However, you can save time and energy by consciously creating test cases that are reusable and easy to maintain.

  • Create test cases with the end user's perspective in mind. Remember throughout the test case writing process that you're trying to step into the user's place. Aligning your exploratory testing methods with the user's perspective will help you create efficient and relevant software application test cases.

Consider creating a reusable test case template.

A test case template provides a flexible but basic structure that you can customize on an as-needed basis. It can also serve as a checklist to ensure all essential elements have been included. Many testers use spreadsheets with one test per row and the test elements in columns. Here are a few elements you can add to your test case template:

  • Test Case ID

  • Test Case Description

  • Pre-Conditions

  • Test Steps

  • Test Data

  • Expected Result

  • Post Conditions

  • Actual Result

  • Status

Benefits of writing high-quality test cases

Writing test cases allows you think through every aspect of your software and makes it easier to identify any software gaps as it develops. Several of benefits emerge when you write formal test cases.

  • Documentation means you can guarantee the coverage of your tests.

  • You can reduce software maintenance and bug fixes and support future costs. 

  • Test cases can be used again in current and future projects.

  • You can improve the quality of the software and the user experience.

  • A higher quality product means more satisfied customers and higher profits.

Test case management tools help you manage software and hardware development. These tools track your test cases, bugs, and other important information related to testing. 

Countless testing tools are available in the market. If you’re applying for test case writer jobs or a similar role, you might need prior experience with one or more of these tools: 

  • JIRA

  • JunoOne

  • Klaros-Testmanagement

  • QACoverage

  • Qase

  • SPIRATEST by Inflectra

  • TestFLO for JIRA

  • Testpad

  • XQual

  • Xray

  • Zephyr Scale

  • Zephyr Squad

Sharpen your testing skills with Coursera

If you want to gain more experience with quality assurance or testing, consider taking an online course from an industry leader in technology. For example, you can earn a Google IT Automation with Python Professional Certificate for your resume while learning more about test automation, troubleshooting, and debugging.

Keep reading

Updated on
Written by:

Editorial Team

Coursera’s editorial team is comprised of highly experienced professional editors, writers, and fact...

This content has been made available for informational purposes only. Learners are advised to conduct additional research to ensure that courses and other credentials pursued meet their personal, professional, and financial goals.