Open In App

How to Write Test Cases - Software Testing

Last Updated : 23 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Writing effective test cases is a critical skill in software testing, ensuring that the software meets the desired functionality and quality standards. A well-written test case provides clear instructions to verify specific features of the software and helps in identifying potential defects easily.

The Flow of Test Case:

flow-of-Test-Case
Flow of Test Case

Test Case Template

A Test Case Template is a simple, organized format used in software testing to create test cases. It helps ensure that all tests are written clearly and consistently.

Let's look at a basic test case template for the login functionality.

  • The Test case template contains the header section which has a set of parameters that provide information about the test case such as the tester's name, test case description, Prerequisite, etc.
  • The body section contains the actual test case content, such as test ID, test steps, test input, expected result, etc.

Below is the table that shows the basic template of a test case:

Fields Description
Test Case ID Each test case should have a unique ID.
Test Case Description Each test case should have a proper description to let testers know what the test case is about.
Pre-Conditions Conditions that are required to be satisfied before executing the test case.
Test Steps Mention all test steps in detail and to be executed from the end-user's perspective.
Test Data Test data could be used as input for the test cases.
Expected Result The result is expected after executing the test cases.
Post Condition Conditions need to be fulfilled when the test cases are successfully executed.
Actual Result The result that which system shows once the test case is executed.
Status Set the status as Pass or Fail on the expected result against the actual result.
Project Name Name of the project to which the test case belongs.
Module Name Name of the module to which the test case belongs.
Reference Document Mention the path of the reference document.
Created By Name of the tester who created the test cases.
Date of Creation Date of creation of test cases.
Reviewed By Name of the tester who reviews the test case.
Date of Review When the test cases were reviewed.
Executed By Name of the tester who executed the test case.
Date of Execution Date when the test cases were executed.
Comments Include comments which help the team to understand the test cases.

In the given template below it's identifiable that the section from module name to test scenario is the header section while the table that lies below the test scenario (from test case ID to comments) is the body of the test case template.

Here a test case template for login functionality has been created with its parameters and values.

test-case-template
Test Case Template

Parameters of a Test Case

Here are the important parameters of the testcase which is helping to the development process of software:

  • Module Name: Describes the functionality being tested.
  • Test Case ID: A unique identifier for each test case.
  • Tester Name: The name of the person conducting the test.
  • Test Scenario: A brief description of what the test will cover.
  • Test Case Description: Specifies the condition or feature being tested.
  • Test Steps: A detailed list of actions to execute the test.
  • Prerequisite: Any conditions that must be met before starting the test.
  • Test Priority: Indicates the order of importance for testing.
  • Test Data: Inputs required for the test.
  • Test Expected Result: The expected outcome of the test.
  • Actual Result: The actual outcome after test execution.
  • Environment Information: Details of the test environment, like OS and software version.
  • Status: Whether the test passed, failed, or is not applicable.
  • Comments: Any additional notes about the test.

Here is an example of how the parameters of a test case can be represented

Example Test Cases for a Login Page

Below is an example of preparing various test cases for a login page with a username and password.

Unit Test case: Here we are only checking if the username validates at least for the length of eight characters.

Test Id Test Condition Test Steps Test Input Test Expected Result Actual Result Status Remarks
1. Check if the username field accepts the input of thirteen characters. 1. Give input geeksforgeeks Accepts for thirteen characters. Accepts for thirteen characters. Pass None

Here it is only checked whether the passing of input of thirteen characters is valid or not. So since the character word 'geeksforgeeks' is entered then the test is successful it would have failed for any other test case.

Functionality Test case: Here it is checked whether the username and password both work together on the login click.

Test Id Test Condition Test Steps Test Input Test Expected Result Actual Result Status Remarks
1. Check that with the correct username and password able to log in.

1. Enter the username

2. Enter the password

3. Click on the login

username: geeks for geeks

password: geeksforever

Login successful Login successful Pass None
2. Check that if with an incorrect username and password able to not login.

1. Enter the username

2. Enter the password

3. Click on the login

username: geeksforgeeks

password: geekstogether

Login unsuccessful Login unsuccessful Pass None

Here it is being checked whether passing wrong and right inputs and if the login functionality is working or not, it's showing login is successful for the right credentials and unsuccessful for the wrong ones, hence both tests have passed otherwise would have failed.

User Acceptance Test Case: Here the user feedback is taken if the login page is loading properly or not.

Test Id Test Condition Test Steps Test Input Test Expected Result Actual Result Status Remarks
1. Check if the loading page loading efficiently for the client. 1. Click on the login button. None Welcome to the login page. Welcome to the login page. Fail The login page is not loaded due to a browser compatibility issue on the user's side.

Here it is being checked in by clicking on the login button if the page is loaded and the 'Welcome to login page' message is displayed. The test has failed here as the page was not loaded due to a browser compatibility issue, it would have loaded if the test had passed.

When do we Write Test Cases?

Test cases are written in different situations:

  • Before development: Test cases could be written before the actual coding as that would help to identify the requirement of the product/software and carry out the test later when the product/software gets developed.
  • After development: Test cases are also written directly after coming up with a product/software or after developing the feature but before the launching of a product/software as needed to test the working of that particular feature.
  • During development: Test cases are sometimes written during the development time, parallelly. so whenever a part of the module/software gets developed it gets tested as well.

Test cases are typically documented in tools like Excel, Jira, or dedicated test management platforms. These tools help organize and track the test cases, ensuring they align with the required specifications with ongoing development. Test cases help in further development and make sure that we are meeting all the needed requirements.

Test Case Management Tools

Test case management tools are important in managing test cases efficiently, making the testing process faster and less time-consuming compared to traditional methods. These tools provide features such as advanced dashboards, bug tracking, progress tracking, custom templates, and integration with other testing tools. Test case management tools help testers organize, manage, and execute their tests more effectively.

Here are some of the most popular test case management tools:

  1. TestLink: TestLink is a widely used test management tool that offers easy integration with bug tracking systems and provides a user-friendly interface to manage test cases, test plans, and test runs.
  2. X-ray: X-ray is a test management tool for Jira, designed to manage both manual and automated tests. It integrates seamlessly with Jira, providing robust reporting, traceability, and tracking for test cases.
  3. TestRail: TestRail helps manage test cases, test plans, and test runs. It offers real-time insights into testing progress and enables better collaboration between QA teams, helping them streamline their test case management processes.
  4. PractiTest Ltd.: PractiTest is a test case management tool that focuses on organizing test cases, creating test plans, and offering detailed reports. It allows for seamless integration with popular bug tracking systems and other testing tools.
  5. TestCollab: TestCollab is a tool for managing test cases, test plans, and testing progress. It provides strong reporting and analytics features to give teams insights into their testing efforts.
  6. Kualitee: Kualitee is a comprehensive test case management platform that supports manual and automated testing. It provides features for test case creation, execution, and tracking, along with strong integration with bug tracking tools.
  7. Qase: Qase is an easy-to-use test management tool that supports manual test execution and test case management. It integrates with various CI/CD tools and offers powerful reporting and analytics features.
  8. Testiny: Testiny is a lightweight test management tool that provides an intuitive interface for managing test cases. It allows easy tracking of test executions and facilitates collaboration within teams.
  9. TestMonitor: TestMonitor is a test case management platform designed to enhance collaboration among teams. It offers comprehensive features like test case management, test plan creation, bug tracking, and detailed reporting.
  10. SpiraTest: SpiraTest is a test management tool that allows users to manage test cases, bugs, and requirements in one integrated platform. It provides full traceability and powerful reporting for effective test case management.

Formal and Informal Test Case:

  • Formal Test Cases: Formal test cases are test cases that follow the basic test case format. It contains the test case parameters such as conditions, ID, Module name, etc. Formal Test cases have set input data and expected results, they are performed as per the given order of steps.
  • Informal Test Cases: Informal test cases are test cases that don't follow the basic test case format. In these, as the tests are performed the test cases are written in real-time then pre-writing them, and the input and expected results are not predefined as well.

Benefits of Writing High-Quality Test Cases

Writing high-quality test cases offers numerous benefits that contribute to the effectiveness and efficiency of the software testing process. Some benefits are listed below:

  • Improved Test Coverage
  • Enhanced Communication
  • Consistency and Repeatability
  • Efficient Defect Identification
  • Improved Test Automation
  • Increased Confidence in Software Quality

Similar Reads