Netsparker Web Application Security Scanner

How to Write Good Test Cases?

Writing test cases is one of the key activity performed by the tester in the Software Testing Life Cycle(STLC). But the writing effective test case is a skill & which can be done by doing in-depth study of application for which writing the test cases and most important is the experience. The approach for writing good test cases will be to identify, define and analyze the requirements.


What is test case?

A test case is a set of conditions or variables under which a tester will determine whether a system under test satisfies requirements and works correctly.

Typically, test cases should be small, isolated and atomic. Test cases should be easy to understand and steps should be executed fast. They should independent with each other & fail/pass independently from one another. Fairly, each good test should have defined its expected result.


What all fields needs to be included in test case?

Test Case ID Unique Test Case Identification Number
Module to be tested Module name or Requirement ID, generally used to prepare requirement traceability matrix between test cases and requirement.
Assumptions If any
Test Data Test data required for executing the test case.
Test Steps Detailed steps for test case execution.
Expected results How application should behave after executing the above testing steps.
Result Pass or Fail
Comments Add Additional information like screenshot, login credentials, for developer to get the exact information for developer.

You can use start writing test cases in the excel sheet. You can continue with excel or choose open source or paid test case management tool from the variety of list. There are different test case management tools like Quality Center, Test Director or TestLink etc. in the market, these tools supports excel import feature, so you can import above written test case easily.

How to Write Good Test Cases?

Once the test case is executed you should mark the result of test case. Many tools provide the execution of test case step by step. If you are using excel sheet then you can simply mark the status of test case. If the test case is failed then you should log a defect add same defect id in the test case while executing the test case. This will really help for tracking the testing progress & measure the quality of the application. While writing the test cases the steps should be detailed and clear. I personally do not agree to write the large number of steps in the test cases.


How to write test cases?
Here is a excel & word test case format: Download Sample Test Case Format


How To Write Effective Test Cases?

While writing the test cases you need to follow some steps to make sure that you will write good and effective test cases.

1. Identify The Scope And Purpose Of Testing

First key point before start writing effective test cases is that you need to identify the testable requirements. You need to understand the purpose of testing & you must understand the features and user requirements.

2. Define How To Perform Testing Activities

Before start writing the effective test cases, you should first start defining the effect test scenarios and to start defining effective test scenarios you should have better understanding of functional requirements of an application. You must know about what all operations can be used, so that the test scenarios & test cases can be written based on these important guidelines.

3. Identify Non-Functional Requirements.

Along with the function requirements, the non-functional requirements are equally important. Basically in non-functional requirements such as Operating system, hardware requirements, security features to be considered and also identity additional prerequisites required for testing like test data preparation.

For example, Consider a scenario where form accepts the user information, in such case the proper timeout should be defined by the developer to make sure that the application should not timed out while entering the user information into application. At the same time if the user is idle for few time, so system should automatically logged off after the predefined delay to ensure that security of application is not violated.

4. Define The Test Case Framework

Depends of the systems requirements the test case framework can be designed. Typically, the test cases should cover functionality, compatibility, UI interface, fault tolerance, and performance of several categories.

5. Become Familiar With The Significance Of Software Modules

It is simple and easy to understand analyze the significance of the software modules there in the application under test. On the other hand it is also equally important to identify the integration with internal modules. So to write good test cases you should familiar with the importance of these & consider same while preparing the test cases.

Let’s take a simple example of Online Shopping website testing, while testing from shopping cart to order checkout you also needs to consider Inventory Management & check if upon successful order checkout same can be deducted from store.

6. Structuring Of Test Cases

At this point you have all the necessary information to start writing test cases. Here we are talking about basic structure of test case & what all comprises in the test case. In above steps we have prepared list of test scenarios prepared from the requirements, now we can elaborate the test scenarios & will prepare test cases. Each test scenario may have one or multiple test cases.


Important Points To Write Your Test Cases More Effective:

1. Test Cases need to be simple steps, transparent and easy to understand.

The steps in the test cases should be detailed & to the point, so new tester can easily execute the test case with ease. The purpose and scope of test cases should be well defined in the test case i.e. Test cases should be self explanatory. Along with detailed steps all pre-requisite test data should be specified in the test case itself.
Test cases should be reviewed by peer members.

2. Test Cases Should Be Valid, Brief And Short

Test cases should have only necessary and valid steps. If single test case having too many test steps to be performed then this may lose concentration & aim of test case. So, single test case should have one expected result and not try to cover too many expected results. Create Test Case with thinking of end users point of view. Don’t repeat the test cases, if same steps are needed to execute then provide the test case id in the pre-requisite step.

3. Test Cases Should Be Traceable

Each and every test case should be traceable and it should be linked to “Requirement ID”, which help to check the 100% coverage of requirements & this will help to identify the tester is performing testing for all requirements and no any requirement is missed to test. One more key advantage of doing linking “Requirement ID” to test case is, if any of the requirement gets changed then based on this mapping we can easily do the impact analysis & change the impacted test cases accordingly. 

4. Test Cases Should Be Maintainable

Test cases should be written in such a way that it should be easy to maintain. Let’s take scenario where after completion of writing test cases the requirement gets changed, then tester should effortlessly able to maintain the test suite of test cases.
Each test case should have unique identification number which help to link the test cases with defects and requirements.

5. Implement Testing Techniques – Positive And Negative Test Cases

While writing test cases few test case design methods should be used like equivalence classes portioning, boundary value analysis, normal and abnormal conditions. You should also consider negative testing, failure conditions and error handling which could help to discover most probable defects in the code. Don’t assume any functionality, write the test cases with reference to requirement specification document.

6. Preparation Of Test Data For Diversity Of Test Cases

Sometimes, variety of test data (pre-requisite) is required for executing the test cases like valid data to test positive test cases, invalid data to test negative test cases, legitimate invalid data to test boundary value conditions, illegal and abnormal data to test error handling and recovery test cases.

7. Preparation Of Non-Functional Testing Aspect

Different set of test cases should be prepared for the basic performance testing like multi-user operations and capacity testing. Also cover the test cases for Browser supports in case of Web application testing. Test cases for Security aspects should be cover for example user permission, session management, logging methods.

8. Preparation Of Usability Testing Aspect

Test cases should cover the usability aspects in terms of ease of use. The test cases should cover for overall style & color of the page & check same against the signed off mock-up designs if any or need to check the style with overall style guidelines. Basic spellings, English grammars, population of dependent drop-down list values should be cover under usability testing aspects.


Conclusion on “How to Write Good Test Cases?”

A test case is to be written to check if features of application are working as expected. Basically a test case contains Test Case ID, Test Steps, Expected result, Result fields. While writing test case keep in mind that all test cases should be simple and easy to understand. First you should cover the Functional test cases then you should include the non-functional test cases. Both test cases are equally important to improve the quality of application under test.

If you have more creative and effective techniques for writing test cases which you think it will help others testers friend then please share in comments below.

Happy Testing!!

13 comments to How to Write Good Test Cases?

  • sathyan

    SIR,FIrst what we have req 4 test cases and how can i write testcase giv some exam

  • Sunil

    Thanks for sharing post, I really liked it.

  • Abhishek

    Please give some example of converting any requirement (written in SRS) into test case. It will really help us.

  • Savan

    gr8 article

  • sowmya

    gud article

  • naresh


  • Shiva

    7 Stars rating from my side….
    Nicely explained and extremely simple language is used to elaborate.

  • HieuPham

    Thanks for sharing!
    But Could you get example a test case detail?

  • selvi

    can i get load testing sample test cases for facebook websit………

  • Eversendai admin

    Give example for how to write test case

  • Sampath Gattu

    Nicely explained

  • Iwa.Boyko

    Thank you.Very useful article.

  • Ritesh Keshiya (QA)

    I found an error in this page, When user scroll down the page, then “Join Our Premium Testing Classes” and above “Recent STC Posts” jumbled up with each other.

    Steps to reproduce:
    1. scroll down the page slowly.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>