Best practices for writing test cases

Janvi B Bhuva

Nov 06, 2020 | 4 min read

What is a Test Case?

Test cases are a specific set of conditions that are performed on the software application to achieve a determined output and to verify the functionality of the feature.

Testcases guide the testers through the sequence of steps to validate whether the software application is free of bug, and it is working as required by the end-users. Test cases are the base of the testing process for any software application or system. Test cases clarify the tester what needs to do for testing the software.

Why Documenting test case is important?

The proper documentation with all test scenarios defined is necessary for testing work. When any issues encounter from the client-side, it creates an unacceptable impression on the company. And like always, the attack comes on QAs. So Testcase document is prepared with the set of conditions that need to be performed on the software application to confirm the expected functionality. Test scenarios should have the proper description which the user might face using the software.

Who create test cases?

In the domain of software testing, test cases are commonly used by a tester. But also some organizations prefer preparing the unit tests which are made by developers.

The person who writes the test is not always the person who is going to execute it. So the drafted test case should allow any tester to understand and execute the test case. For that, test cases should be easy to understand, and most probably should be independent of one another for a better understanding. The test cases should be understandable to anyone of any level can read, understand, and be able to execute those test cases.

How to write effective test cases?

  • Use a strong title that itself describes the characteristic of the module.
  • Use a short description i.e easy to understand and describe the goal of the test case.
  • Mention the steps to follow to achieve the specific objectives.
  • Include the preconditions that must be met prior to the test being executed.
  • Include the assumptions that are to be achieved by following the steps.
  • Include the expected results that describe what should be the results of the test steps.
  • Include the actual results that describe how the test is behaving by following the steps.
  • Include the test result “Pass/Fail” against the particular test case. If the testers able to achieve the expected output then will mention Pass else if the testers fail to achieve the expected output ten will mention Fail.
Image source: tacticalprojectmanager.com

What things to be included while writing test cases?

The test case contains the below aspects:

Test case ID: Unique numbering for identifying the test cases.
Process Name: The name of the feature for which the test case is written.
Test Case Description: A short description of the feature that is being tested.
Criteria Tested: The test scenario for which the case is being tested.
Expected result: The output to be achieved as per requirements provided is mentioned here.
Actual result: The actual result will be filled during the execution of the test case.
Test result: The test result will be marked as pass and fail if the actual result meets the expected result.
Comments: Any suggestions or the thing we observe can be mentioned here.

Here's a sample testcase for the Login functionality:

Template URL

What important things to remember while writing test cases?

Some of the points to be considered while writing the test cases are:

  • The test case should be different flavored i.e. “Positive and Negative”.
  • The test case should be measurable so that at the end of the test run, we can say whether the test passed or not.
  • The test case should be unique for the scenario you are writing for.
  • The test cases should be specific to a specific function and the point.

Why do we write test cases?

  • Test cases prepared in advance helps the testers to recall the functionality or feature when it comes back to testing after a long interval.

  • Test cases are prepared so that at the end of the test run we can have a clear idea for the following things:

    1. Which features have been tested?
    2. How many features are stable?
    3. The number of defects founds in the respective module.
    4. How many test cases have been executed and passed?
  • When a new developer or tester is hired for the ongoing project, they can pick up and test the application without much training or much help from others if the test cases are designed in the proper format. As the test cases define exactly how to use the system what is the expected output.

  • When there are more testers involved in the same project there are chances that the same feature is going to be tested by other testers so the documentation of the test case should be done thoroughly how to test the feature to let future testers run your test case whenever needed.

  • In the near future, if you are looking forward to automating the script, you need to have a detailed test case so that you can know what to script.

So here comes to the end of my topic !