How to Write Test Cases

how to write test cases

Development of test cases plays a key role in the efficacy of a product. Designing test cases should be done in such a way that reduces the bug leakage ratio to a very minimum. From beginners to experienced professionals, you must know the art of writing test cases covering all basic to edge-case scenarios. Any tester can write test cases but optimizing them is an art. Let’s first look at the very essentials of the tutorial.

What are Test Cases?

A test case is a test scenario to test functionality with a different set of input and parameters. We test the expected Result of the test case with the expected one. The test case is marked as passed if the output matches and is marked as failed if the output of expected and doesn’t match. Test cases can be executed manually or via automation.

Test cases are maintained in test management tools like Jira, HP QC, and others. Let’s look at the main components of test cases.

  • Test Case ID
  • Test Case Description
  • Assumptions
  • Test Data
  • Pre-Condition
  • Test Steps
  • Expected Test Result
  • Actual Test Result
  • Status Pass/Fail
  • Comments

Types of Test Cases

There are different test cases based on the testing methodologies you are following in your project. Some are Functional, API, Performance, Security, Usability, UI, Database, and Unit Test Cases. Functional Test Cases are the ones that are written to test every functionality of the application against user requirements defined by stakeholders. API Test Cases are the ones that are executed before UI is developed for functionality. We test various APIs against different sets of inputs and conditions. Performance and Security Test cases are used to test the application’s load capacity and vulnerabilities, respectively.

Usability Test Cases are executed to evaluate how user-friendly is our application. Database test cases are mostly SQL or No SQL-based testing. Unit test cases are written by developers to test their code effectively.

How to Write Test Cases in an Excel Sheet

For writing test cases in excel you need to make an excel sheet. There is no specific template for writing test cases that have 10 different columns – Test Case ID, Test Case Description, Assumptions, Test Data. Pre-Condition, Test Steps, Expected Result, Actual Result, Status, and Comments. Suppose you want to write a test case to test a login functionality.

Test Case ID:  Test Case ID will be the test case number of story number in JIRA.

Test Case Description: The description will be a short description of the functionality.

Assumptions: Assumptions should be mentioned in the assumptions columns if any.

Test Data: Test Data is the data with which you are performing the testing.

Pre-condition: Pre-condition should be anything that is done before the execution of the test case.

Test Steps: In Test Steps, you must mention steps like Login to application, Enter Username, and password, click the login button, Verify the page redirects to splash page.

Expected Result: The expected Result should indicate the behavior of the application after the execution of the test case.  For successful Login expected Result would be a redirection to the splash page.

Actual Result: The actual Result indicates the actual behaviour of the application on the execution of the test case.

Status: Status can be marked as passed or fail depending on the actual Result.

Comments: Last is the optional comments.

Test Cases Example

Let’s take an example to write a Test cases example for a web application. They will be around Login, logout functionality test cases, and other functionality-related test cases. UI and performance-related test cases will also be part of test cases. With the different number of browsers these days, it is very important to test the web application on different browsers with different versions. Hence compatibility test cases are also very important.

Test Case ID Test Case Description Test Data Test Steps Expected Test Result Actual Test Result Status Pass/Fail
TC_01 Verify whether a user is able to login with valid username and password Username : ABCDEFG
Password: 123456
1. Open URL : {website homepageurl}
2. Click on Login button from header and navigate to login page
3. Enter registered user’s username in the username field
4. Enter valid password
5. Click on Login button
User should be logged in gracefully Same as Expected Pass
TC_02 Verify whether it allows user to login with a valid username and an invalid password. Username : ABCDEFG
Password: 1233333
1. Open URL : {website homepageurl}
2. Click on Login button from header and navigate to login page
3. Enter registered user’s username in the username field
4. Enter invalid/incorrect password
5. Click on Login button
1. It should not allow user tologin
2. It should display validation message for invalid credentials
3. Incorrect input filed should get highlighted with different color
Same as expected Pass
TC_03 Verify the login page when the fields are blank and Submit button is clicked. N/A 1. Open URL : {website homepageurl}
2. Click on Login button from header and navigate to login page
3. Click on Login button
1. It should not allow user tologin
2. Validation message should be display to enter credentials
3. Username and Password field should get highlighted with different color
Same as expected Pass

How to write effective Test Cases

Now, we have looked at the way test cases are written and how to optimize them. This mystery is still not solved yet. Let’s now dig into detail to write effective test cases.

  • Always stick to user requirements and never write test cases on assumptions. Always stick to the SRS document or clear your doubts, if any, but never deviate to another lane while writing test cases.
  • As we follow agile, it is very important to update yourself on the latest functionalities. Communicate as much you can with stakeholders and technical guys so that you can keep the SRS updated with agile dynamism.
  • The test Case description should always be to the point so that it is very easy to segregate the test cases on functionality by just reading the Description.
  • Always write test cases by mimicking yourself as a customer. Put yourself in the shoes of a customer, which will help you cover all test scenarios that a customer can execute.
  • Your test steps should be granular instead of writing lengthy, detailed test steps. They should be crisp and clear. If a step is big, break it into granular steps to make the test case easy to understand and execute for anyone.
  • Test Cases should be assigned to you if you have written them. Ownership of test cases is very important for the maintenance of test cases.
  • Use a test management tool to organize your test cases, test plan, test cycles, and reports. It will act as a common medium for all team members, and it will help you better manage your test cases.
  • It is very important to get the test cases reviewed by your team so that no duplicate test cases are written which help to get rid of unnecessary test cases.
  • Exploratory testing is very important to find bugs. So, it is very important to have a mindset of a critic in your mind while executing test cases so as not to miss important bugs.
  • Don’t have too many objectives in a test case. Always stick to the fact that a single test case will follow a single objective.
  • Prioritization of test cases is very important in crunch times. It is very you have a priority defined for your test cases so that you don’t miss your test cases when you have very little time left.
  • Learning automation and starting with the automation of manual test cases is equally important as this will reduce manual efforts and will help in finding a greater number of bugs. You must be thinking How to write test cases in java. You can use any automation tool like Selenium/ Cypress with Java to write your functional test cases. This can be integrated with reporting tools like TestNG, Allure, and Extent for amazing reports.
  • Always have cross-browser test cases so that no bugs are leaked to production.
  • One more thing you must be confused at the fact: Who writes UAT test cases? User acceptance testing is done by stakeholders in pre-prod and production. Hence, we leave this part for business analysts and stakeholders to have crucial test places in place by following the above steps.


Now, you must be clear on how to write effective test cases. Start downloading our sample test case document and continue with test case designing. It takes time to be an expert in writing test cases, but in no time, you will be an expert by following the above tips. If you still have any doubts get a free estimation from us and make your test cases development process more efficient at minimum cost.

Related Posts