How to Write Test Cases: A Complete Guide for Software Testers
Learning how to write test cases is a crucial skill for quality assurance professionals and developers alike. This comprehensive guide will walk you through the process of creating clear, concise, and effective test cases.
Whether you’re new to software testing or looking to refine your skills, mastering how to write test cases in software testing will significantly improve your ability to identify bugs, validate features, and contribute to the overall quality of software products.

Don’t miss: Related Test Cases
What is a Test Case in Software Testing?
A test case template is a document that comes under one of the test artifacts, which allows testers to develop the test cases for a particular test scenario in order to verify whether the features of an application are working as intended or not. Test cases are the set of positive and negative executable steps of a test scenario which has a set of pre-conditions, test data, expected results, post-conditions, and actual results.
Most of the companies are using test case management tools such as Quality Center (HP QC), JIRA, etc., and some of the companies still using excel sheets to write test cases.
Check the below video to watch “How To Write Test Cases Manually”
What is the difference between Test Scenario vs Test Case?
A test scenario is a high-level description of what to test, outlining the overall functionality or feature being evaluated within a system. In contrast, a test case is a detailed document that specifies the exact conditions, inputs, and expected results for a particular test, providing step-by-step instructions for execution.
Essentially, test scenarios focus on “what” needs to be tested, while test cases dive into the “how” of the testing process.
Test Scenario: A test scenario outlines what to test and helps ensure that all important functions are covered. Learn more on how to write test scenarios here.
For example, Verify the login functionality of the Gmail account.
Test Case: Test Case is a detailed set of steps to follow in order to verify a particular feature or function. It includes input data, the action to perform, and the expected result.
Here are some test cases using the previous example scenario (Verify the login of the Gmail account).
1. Enter a valid User Name and valid Password
2. Enter a valid User Name and invalid Password
3. Enter an invalid User Name and valid Password
4. Enter an invalid User Name and invalid Password
Also, read the difference between a Test Scenario and a Test Case here.
Types of Test Cases
Understanding the different types of test cases—including functional, integration, performance, and security test cases—enables testers to create comprehensive test strategies that ensure quality and reliability in software development.
- Positive Test Cases: Positive test cases are designed to verify that the application behaves as expected when provided with valid input. They test the core functionalities of the software, ensuring that the right output is produced under normal circumstances.
- Negative Test Cases: Negative test cases focus on validating the application’s response to invalid input or unexpected user behaviour. They help confirm that the software can handle errors gracefully and maintain stability.
- Boundary Test Cases: Boundary test cases assess the performance of the application at the edges of input ranges. Testing with values at the upper and lower limits ensures that the system can handle extreme conditions without failure.
- Functional Test Cases: Functional test cases verify that specific functions within the software operate according to the requirements. They ensure that the application performs its intended tasks correctly.
- Unit Test Cases: Unit test cases are designed to test individual components or functions of the software in isolation. By focusing on specific units of code, developers can identify and fix bugs early in the development process, ensuring that each unit operates correctly before integration with the rest of the application.
- Integration Test Cases: Integration test cases examine the interactions between different modules or components of the system. The goal is to identify any issues that may arise when parts of the application work together.
- System Test Cases: System test cases ensure that all components work together as intended and adhere to specified requirements. It is conducted in an environment that closely mimics production conditions, allowing for the identification of integration and interface issues that may not be evident during earlier testing phases. System test cases encompass a variety of scenarios, including user acceptance testing (UAT) to validate that the system meets business needs and expectations, providing confidence in its readiness for deployment.
- User Acceptance Test Cases: User acceptance test cases are conducted to verify that the software meets the needs and requirements of end-users. Typically performed by actual users, these tests evaluate whether the application is ready for deployment and if it aligns with user expectations and business objectives.
- User Interface (UI) Test Cases: UI test cases focus on the visual elements of the application. They check if the UI is user-friendly, correctly displays information, and adheres to design specifications.
- Performance Test Cases: Performance test cases evaluate how the application performs under various conditions, such as heavy load or limited resources. They are crucial for ensuring that the software remains responsive and stable during peak usage.
- Usability Test Cases: Usability test cases assess how easy and intuitive the application is for users. They involve gathering feedback from real users to determine if the software meets their needs effectively.
- Security Test Cases: Security test cases focus on identifying vulnerabilities within the application. They test for weaknesses that could be exploited by attackers, ensuring that user data and application integrity are protected.
- Smoke Test Cases: Smoke test cases serve as a preliminary check to determine if the core functionalities of an application are working properly after a new build or update. These tests are designed to quickly assess whether the application is stable enough for further testing, allowing teams to identify major issues early in the development cycle.
- Regression Test Cases: Regression test cases ensure that previously developed and tested features still function correctly after changes or enhancements to the application. Regression testing is essential for maintaining system stability and confirming that new code does not introduce any unforeseen issues.
- Exploratory Test Cases: Exploratory test cases involve simultaneous learning, test design, and test execution. Testers apply their intuition and experience to explore the application, allowing them to identify unexpected behavior and discover defects that scripted tests might overlook. This approach is invaluable for enhancing software quality, particularly in complex or dynamic systems.
- Alpha Test Cases: Alpha test cases are conducted in a controlled environment, usually within the developing organization, before the software is released to external testers. These tests are performed by a small group of stakeholders or end-users to identify bugs and usability issues. The goal is to ensure that the software meets quality standards before it moves to beta testing.
- Beta Test Cases: Beta test cases are executed during the beta phase, where the application is released to a limited audience outside the development team. This phase allows real users to test the application in a real-world environment, providing valuable feedback and identifying defects that may not have been uncovered during earlier testing phases. Beta testing is crucial for refining the software before its final release to the public.
- Database Test Cases: Database test cases focus on validating the integrity, accuracy, and performance of the database. They include testing database operations such as data retrieval, updates, and deletions, ensuring that the database functions correctly and efficiently while maintaining data consistency and security.
General Test Case Template Format
Find the test case template screenshot below:
How To Write Test Cases in Manual Testing
Writing effective test cases is essential for thorough and accurate manual testing. Well-crafted test cases help ensure that every aspect of the application is tested, leading to the identification of bugs and issues before the product goes live. This guide covers the key steps in creating comprehensive and structured test cases, from understanding requirements to organizing and executing tests.
#1. Analyze Requirements
- Review Project Documentation: Begin by collecting all essential project documents, such as design specifications, and user documentation etc., This will give you a clear overview of the project scope and ensure access to important information for future steps. Evaluate each document for relevance and clarity, identifying any discrepancies that need further investigation.
- Clarify Ambiguities with Stakeholders: Effective communication is essential for reducing uncertainties in project outcomes. Reach out to stakeholders to clarify any ambiguities in documentation, ask targeted questions, and actively listen to their feedback. Use paraphrasing to ensure understanding and document insights or changes. This collaborative approach fosters consensus and encourages shared ownership and accountability in the project.
- Prioritise Requirements: Prioritizing requirements is crucial for delivering the most valuable features on time in a project. Start by categorizing user stories based on business value, user impact, and technical feasibility. Use methods like MoSCoW technique to facilitate stakeholder discussions and regularly re-evaluate priorities to adapt to market changes or user feedback. This iterative approach aligns development with user expectations and optimizes resource allocation for meaningful outcomes.
#2. Define Test Case Structure
Let’s see the steps on how to write manual test cases in detail.
Step #1 – Test Case ID
Assign a unique identifier to each test case. This helps in tracking and referencing the test case easily.
Example: TC_Login_001: Verify the login of Gmail
Step #2 – Test Case Description
Provide a concise description of what the test case will verify. This should summarize the overall purpose of the test case.
Example:
Test scenario: Verify the login of Gmail
Test case: Enter a valid username and valid password
Step #3 – Pre-Conditions
List any prerequisites that must be met before executing the test case. This could include specific setups or configurations.
Example: Need a valid Gmail account to do login, or Test environment should be similar to production environment.
Step #4 – Test Steps
To execute test cases, you need to perform some actions. Outline the specific steps to be followed during the test. This should be detailed enough for anyone to replicate.
Example:
- Launch the applications login page.
- Enter Username.
- Enter Password.
- Click Login button.
- Verify whether the user has been logged in successfully.
Step #5 – Test Data
Specify the data that will be used during testing. Include any necessary input values that the test steps will require.
Example:
- Username: rajkumar@softwaretestingmaterial.com
- Password: STM
Step #6 – Expected Result
Describe the expected result after executing the test steps. It might be anything such as Home Page, Relevant screen, Error message, etc., This sets the benchmark for determining pass or fail.
Example: Successful login
Step #7 – Post Condition
Detail the state of the system after the test has been executed. This is important for understanding the impact of the test.
Example: The Gmail inbox is displayed upon entering valid credentials.
Step #8 – Actual Result
Record what actually happened when the test case was executed. This is crucial for comparing against the expected result. Based on this result and the expected result, we set the status of the test case.
Example: Redirected to Gmail inbox
Step #9 – Status
Indicate whether the test case has passed, failed, or is blocked. This provides quick insight into the test case’s outcome. If the actual and expected results are the same, mention it as Passed. Else make it as Failed. If a test fails, it has to go through the bug life cycle to be fixed.
Example: Result: Pass
Other important items in a test case template are:
- Project Name: Name of the project the test cases belong to
- Module Name: Name of the module the test cases belong to
- Reference Document: Mention the path of the reference documents (if any such as Requirement Document, Test Plan, Test Scenarios, etc.,)
- Created By: Name of the Tester who created the test cases
- Date of Creation: When the test cases were created
- Reviewed By: Name of the Tester who created the test cases
- Date of Review: When the test cases were reviewed
- Executed By: Name of the Tester who executed the test case
- Date of Execution: When the test case was executed
- Comments: Include value information which helps the team
Best Practices To Write Good Test Cases
In this section, we’ll explore best practices to create clear, concise, and robust test cases that not only verify functionality but also improve overall software quality.

- Clear and Concise Description: Use simple language to describe what the test case is meant to validate. This helps everyone understand the purpose without confusion. Some examples are “Go to login page”, “enter username”, “enter password”, “click on login button” and so on.
- Create Test Cases with End User’s perspective: Create test cases by keeping end users in mind. The test cases you create must meet customer requirements.
- Use unique Test Case ID: Assign a unique ID or number to each test case. This makes tracking and referencing them easier, especially during discussions or reporting.
- Add proper preconditions: Clearly state any prerequisites or conditions that must be met before executing the test case. This ensures the tester is aware of the environment needed for a successful test.
- Step-by-Step Instructions: Write detailed, easy-to-follow steps for executing the test case. Each step should be straightforward and require no assumptions.
- Add proper postconditions: In some cases, test cases need to meet some conditions after execution. We need to mention these conditions properly in postconditions.
- Specify the exact expected result: Clearly define what the expected outcome is after executing the test case. This helps testers determine if the test has passed or failed.
- Test cases should be reusable & maintainable: A well-crafted test case is both reusable and maintainable. When developers modify the code, testers must update the test cases accordingly. If our test cases are clear and comprehensible, it becomes easier for anyone—whether the original author or other testers—to make necessary updates. Regularly review and update test cases to ensure they remain aligned with the current application requirements and functionalities.
- Usability for Different Audiences: Design test cases so they can be understood and used by various team members, including those who may not be technical.
- Use of Standard Formats: Follow a consistent format and structure for all test cases to improve readability and ease of use.
- Prioritization: If possible, prioritize test cases based on critical features or components of the application to ensure essential functionalities are tested first.
- Utilize testing techniques: Use testing techniques like Equivalence Partitioning, Boundary Value Analysis, Decision Table, State Transition, Exploratory Testing, and Error Guessing whenever necessary. Software test design techniques are used to derive the test cases from the Requirement Specification document and also based on testers’ expertise.
- Reference Related Requirements: Link the test case to related requirements or user stories to provide context and demonstrate coverage of functionality.
- Don’t Assume: When designing test cases, avoid assuming user behavior or system functionality, as this can result in missed scenarios and defects. Prioritize thorough requirement analysis, user feedback, and exploratory testing. Engaging stakeholders can offer valuable insights to refine your testing approach.
- 100% Test Coverage: Achieving 100% test coverage is a key goal in software testing, involving tests that examine every line of code. While it shows that all code has been tested, it doesn’t guarantee error-free software. Well-structured test cases, aligned with the Software Requirements Specification (SRS), are essential for effective coverage. A traceability matrix can help ensure comprehensive testing by mapping test cases to requirements, verifying that all functions and conditions are covered.
- Get peer review: Let your peers review your test cases to uncover the defects in your test case design.
Benefits of Writing High-Quality Test Cases
When writing test cases, always remember that they are the foundation of our quality assurance process. Good test cases help us identify issues early and ensure that our software works as expected. Make sure your test cases are clear, concise, and cover all possible scenarios. This will save us time in the long run and help our team deliver a better product. Always think about how someone else will read and execute your test cases. Here are some benefits of writing high quality test cases.
- Improved Code Quality: High-quality test cases help identify bugs and issues early in the development process, ensuring that the final product is more reliable and less prone to errors.
- Easier Maintenance: Well-written test cases are easier to understand and maintain, allowing developers to make changes to the code without fear of introducing new bugs.
- Faster Development: When test cases are comprehensive, they can quickly verify that new features work as intended, speeding up the development cycle.
- Better Documentation: Test cases serve as documentation for the codebase, helping new team members understand how the system works and what its expected behavior is.
- Increased Confidence: A robust suite of test cases gives developers confidence that their changes won’t break existing functionality, leading to a more agile development process.
- Simplified Debugging: When a test fails, it clearly indicates which part of the code needs fixing, making it much easier to troubleshoot and resolve issues.
- Enhanced Collaboration: High-quality tests facilitate better collaboration between developers and testers, as they create a common understanding of the requirements and expected outcomes.
Popular Test Case Management Tools
Test case management tools play a vital role in organizing and overseeing the software development lifecycle. These tools enable the systematic tracking of test cases, bugs, and other critical data related to testing processes. Some of the popular tools for the test management process are
- PractiTest
- Testmo
- Testpad
- Qase
- Kualitee
- Testiny
- Aqua
- QMetry
- TestRail
Don’t miss this detailed article on Best Test Case Management Tools in the market.
Download Test Case Template
A sample Test Case – Template for your reference.
FAQs – How To Write Test Cases in Software Testing
Who Writes Test Cases?
Test cases are typically written by various stakeholders in the software development process, including testers, developers, and business analysts. Testers are primarily responsible for creating test cases to ensure that the software meets its requirements and functions correctly. Developers may also write test cases to validate their code during the development process, ensuring that new features or fixes work as intended. Additionally, business analysts contribute by defining the criteria based on user requirements, which informs the creation of test cases. This collaborative effort helps ensure thorough testing coverage and enhances the overall quality of the software product.
Does a Manual Tester Write Test Cases?
Yes, a manual tester is responsible for writing test cases. A manual tester designs these test cases based on the functional specifications and user stories, taking into account various test scenarios, edge cases, and potential user interactions. By creating clear and concise test cases, manual testers help ensure comprehensive coverage of the application, facilitate effective testing, and provide a clear reference for future testing efforts.
How do you write a test report for manual testing?
To write a test report for manual testing, begin by summarising the scope and objectives of the testing conducted. Include an overview of the test cases executed, highlighting any critical test results and discrepancies found during testing. It’s important to detail the environment in which the tests were performed and note any limitations or assumptions made. Additionally, provide a conclusion that discusses the overall quality of the application, and if possible, suggest recommendations for improvements based on the findings. Finally, ensure the report is clear and concise, making it accessible to all stakeholders involved.
How to automate test cases
Automating test cases involves several key steps to ensure efficiency and accuracy. First, identify the tests that are repetitive and would benefit from automation. Next, choose an appropriate automation tool that aligns with your project’s needs, like Selenium. Write test scripts using a suitable programming language, and then execute these scripts to validate the functionality of the application. Finally, regularly maintain and update the automated tests to accommodate any changes in the software, ensuring the tests remain relevant and effective.
What is a Formal Test Case and Informal Test Case
A formal test case is a detailed and structured document that outlines specific conditions, inputs, and expected outcomes to validate the functionality of a software application. It follows a predefined format and is often used in regulated environments to ensure compliance and thorough documentation. In contrast, an informal test case is less structured and may not adhere to strict guidelines; it often relies on the tester’s intuition or experience to identify potential issues. Informal test cases can be more flexible and adaptable but may lack the comprehensive documentation found in formal test cases.
How businesses use test cases
Businesses use test cases to ensure that their software applications meet specified requirements and function correctly under various conditions. By systematically defining and executing test cases, organizations can identify defects early in the development process, reduce debugging time, and enhance product quality. Furthermore, test cases facilitate compliance with industry standards and regulations, ensuring that the software operates reliably in production environments. This structured approach not only aids in improving customer satisfaction but also helps in maintaining the company’s reputation for delivering high-quality software solutions.
How do we ensure test cases cover all requirements?
To ensure test cases cover all requirements, it is essential to start with a thorough requirements analysis, establishing a clear understanding of user needs and specifications. Utilizing techniques such as requirement traceability matrices can help track each requirement back to corresponding test cases, ensuring comprehensive coverage. Additionally, involving stakeholders in the review process aids in identifying any missed areas or ambiguities. Regularly updating and reviewing test cases as requirements evolve also guarantees that all critical functionalities remain tested throughout the software lifecycle.
How does writing effective test cases contribute to cost savings in the software development process?
Writing effective test cases significantly contributes to cost savings in the software development process by identifying defects early, thereby reducing the amount of time and resources spent on fixing issues later in the cycle. Early detection allows for quicker iterations and less rework, which can be expensive and time-consuming. Furthermore, well-structured test cases streamline testing efforts, enabling automation where possible and improving overall efficiency. This proactive approach ensures that applications have fewer bugs upon release, minimizing costly post-launch fixes and enhancing the overall return on investment.
How do security test cases differ from other test cases?
Security test cases differ from other test cases primarily in their focus on identifying vulnerabilities, threats, and risks within the application. While traditional test cases often verify functional requirements and performance, security test cases assess how well the application can withstand various types of attacks, such as SQL injection, cross-site scripting, and data breaches. These test cases typically include techniques like penetration testing and vulnerability scanning, aiming to ensure that sensitive data is protected and that the application adheres to compliance standards. This specialized approach requires a different skill set, tools, and methodologies compared to standard functional testing.
How to Write & Manage Test Cases in Jira
JIRA is a bug and issue tracking tool, not a test case management tool. Still, we can use it to manage test cases. There is a workaround for writing and managing test cases in Jira.
The first step is to create a “Test Case” issue type with fields such as “Summary, “Test Steps,” and “Expected Results.”
The next step is to create a “Test Results” subtask to fill in the reports.
The next step is to create “Test Cases” one by one by using the issue type.
Conclusion
Knowing how to write test cases is an invaluable skill in the world of software development and quality assurance. By following the steps and best practices outlined in this guide, you’ll be well-equipped to create comprehensive, efficient, and effective test cases. Remember that writing good test cases is an art that improves with practice. As you apply these techniques to your projects, you’ll not only enhance your testing process but also contribute to delivering higher-quality software products. Continue to refine your approach to writing test cases, and you’ll become an indispensable asset to any development team.
Related Posts – Test Cases
Related posts:
- How To Write Test Scenarios With Examples
- Difference Between Test Scenario Vs Test Case
- 20 Skills Of Highly Effective Software Tester
can we export the same template to HP ALM ?
Hi Akhilesh, almost all the reports in any tool (example HP ALM) has almost similar fields in the test case templates. if you have any queries, pls let me know.
Hi,
Please help to share sample system test package document.
Thanks.
Hi vasanth, I didnt get you. Could you please clearly let me know what exactly you want.
Hi Rajkumar Sir, I am going for an Interview for Software Tester Position in malaysia. i am fresher and still learning. can you help me out. these samples which you posted here can edit and attach with my resume as Test Cases? or i have to do something else. i want some test cases print out with attached to my resume.
Thanks in Advance
Luqman
Hi Luqman, there is no point to attach test cases with your resume. Who asked you to attach test cases along with your resume?