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 guide.

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

Key takeaways

Writing test cases is a multi-step process that requires defining the test case area, providing clear descriptions, and stating the expected result.

  • Test cases provide testers with specific steps to follow to make sure an application is operating properly. 

  • Functionality, performance, unit, user interface, security, and integration test cases are some of the types of test cases available. 

  • You can write test cases in various roles, including as a quality assurance (QA) analyst or software developer.

Learn more about test cases, including what they are, who uses them, and how to write them. If you’re ready to develop your skill set in this area, consider enrolling in the Google IT Automation with Python Professional Certificate. In as little as six months, you can learn how to automate tasks using Python scripts, analyze real-world IT problems, and implement solutions. Upon completion, you’ll have earned a career credential to add to your resume. 

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 Foundations of Software Testing and Validation certificate from the University of Leeds in just six hours. 

What is a test case vs. a 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. 

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 correctly, 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.

Who writes test cases in software testing? 

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.

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 to think through every aspect of your software and makes it easier to identify any software gaps as it develops. Several 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

  • Juno.one

  • Klaros-Testmanagement

  • QACoverage

  • Qase

  • SpiraTest by Inflectra

  • TestFLO for Jira

  • Testpad

  • XQual

  • Xray

  • Zephyr 

  • Zephyr Essential

Read more: What Is Jira?

Discover free resources for your career

Subscribe to Career Chat, our LinkedIn newsletter, to learn about career tips and industry trends. Then, check out these free resources for helpful information about careers in software development:

With Coursera Plus, you can learn and earn credentials at your own pace from over 350 leading companies and universities. With a monthly or annual subscription, you’ll gain access to over 10,000 programs—just check the course page to confirm your selection is included.

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.