Best Practices for Writing Test Cases

21 / Aug / 2017 by Rohit Yadav 0 comments

What is a Test Case?

Set of conditions or variables used by testers to determine whether a system works as expected are Test Cases. These help in validating the coverage of an application.

A test case should be :

  • Easy to understand and execute
  • Accurate
  • Easy to trace as per requirements
  • Repeatable
  • Reusable

Test cases include :

Test cases include various fields which help in traceability of test as per the requirements. Following are the fields which are most likely to be a part of a test case :

  1. Test Case ID – This is a unique ID for identification of a particular test case.
  2. Description – This comprises of a brief detail about what is going to be tested.
  3. Pre-condition – This includes any pre-requisite before moving towards the steps to test.
  4. Test Steps - This includes a step-wise approach to test a particular test case.
  5. Expected Result – This covers what should happen.
  6. Actual Result – This encompasses of what actually happened.
  7. Status (Pass/Fail) – This involves the status of a test case after performing a test, whether a test case was passed or failed.

Best practices to write a test case :

Test cases which are easy to execute are considered as good test cases. They make the testing process more efficient by saving time and effort. We can achieve this by following these 10 best practices :

1) Keeping it Simple and Easy to Understand

A good test case is the one which is easy to understand and execute for the testers. To be a good test case, it should be simple and organized category-wise. Different grouping techniques could be splitting the test cases based on user story or modules like browser specific behaviors etc. This makes it easy to review and maintain. Information given in the test cases should be clear to testers, developers and other stakeholders involved in the project.

2) Including End User Perspective

The end user perspective is a key element when it comes to maintaining the quality of software. Therefore, before drafting a test case, it’s important to think like an end user. Understanding the requirement and the functionality aspects covered by the end user’s perspective will help in identifying test scenarios that arise in real life business conditions.

3) Using Correct Naming Conventions

Naming the test cases in a way that makes it easy for stakeholders to identify as it will help create good and readable test cases. These also help in traceability as per requirements.

4) Providing Test Case Description

A proper test case description will allow users to understand what is being tested and how. Relevant details like the test environment, test data and tools to be used should also be provided.

5) Including Assumptions

All the assumptions and preconditions that are applicable to the test case should be specified clearly in the test case document.

6) Providing Steps Involved

Steps involved to test a test case should be clearly specified so that if any other person performs the test they would be clear about what all steps to follow.

7) Giving Details Of Test Data

The details of the test data for execution of the test case especially in cases where the same data can be reused helps in saving time for the creation of the test data for each cycle to be run. Aim for maximum coverage by choosing a few select values from each equivalence class.

8) Making it Reusable

Ensuring that there is no dependency or conflict among test cases helps in making it modular.  In case there are test cases that are inter-dependent, it should be clearly mentioned in the test document.

9) Assign Testing Priority

Priority of different features in an application is different and therefore assigning a testing priority ensures that during execution, high priority test cases are executed first.

10) Provide The Expected Result And Post Conditions

Expected Results and post conditions help in deciding whether a test case is passed or failed as per the user’s acceptance so these should be clearly mentioned in test cases.

The entire testing process becomes more effective when proper time and efforts are invested in creating the test cases thus ensuring the success of the testing plan for the software project!

FOUND THIS USEFUL? SHARE IT

Leave a comment -