Best Practices To Create Test Cases

What is a test case?

A test case is a set of conditions or variables executed to determine a particular feature or functionality under test, satisfies requirements or works correctly.

Fields:

A test case usually have the following fields:

  • Test case id
  • Title
  • Pre-condition
  • Test case description. Depending upon the organization they can be
    — Steps to be executed and expected result
    — BDD format
  • Test data
  • Pass/Fail
  • Comments if any

In test management tools, different fields can have a different name and customized fields can be added on the basis of project or organization needs.
e.g
a) Depending upon the project, if you are testing a mobile app, it is better to have the following fields
* Operating system- values can be IOS, Android or Windows.
* OS version- values being dependent upon version to be supported
* Device name- values being dependent upon the project or organization
b) If your organization supports automation or project demands then you can have the field as
* Automated- Values as Yes or No

How to prepare yourself to start writing test cases?

1. By doing Requirement Analysis

Go through all the requirements available before starting to write a test case . Gather the requirement from any available document such as a use case, a business case, user story, technical document, any document provided to or by the client, wireframes or by going through already implemented similar functionality etc.

2. By creating a traceability matrix template

Traceability matric helps to track the requirements and to check the current project requirements are met. According to the organizational process
* The traceability matrix can be a separate template depending upon the project’s requirements.
* In agile when stories are properly divided into tasks and subtasks link your test cases, making sure all the requirements have been catered.

Best practices to write test cases

1) Test case title should be self-explanatory

It's a good practice to name a test case in such a way that its understandable for everyone. The test case name should be simple and transparent.

TIP: Use the following naming convention for test case title.
Verify [function to be tested] is [insert a verb that describes an occurrence] when user [action performed by the user]
Example: The title for a test case to verify an error message when user enters incorrect user name can be .
Verify error message is displayed when user enters an incorrect username.

2) Include any precondition and assumptions

If there are any pre-conditions or any kind of assumptions made while creating or running the test case, it needs to be clearly mentioned since the person reading or running the test cases might not have any information about the project.

3) Test case steps should be clear and concise

The instructions and details in the steps should be clear leaving no space for ambiguity.

TIP: Instead of writing paragraphs or long sentences, the steps should be short and concise in the form of bullets. e.g
1) Open the website. > Webiste is displayed
2) Click on the sign up button , enter the form details email and password , click enter button > User successfully signs up
The second step can be written as
2) Click the sign up button > Sign up form is displayed with email and password fields
3) Enter the email and password and tap sign up button > “User has signed up successfully” message is displayed

4) Implement test design technique for creating test data

It’s not possible to check every possible condition in the software application. Hence, in order to get maximum test coverage in a given time, follow test design techniques best suited for the project like equivalence class partitioning, boundary value analysis, decision table, exploratory testing etc .

5) Each test case should test single functionality

A single test case should not be testing multiple testable parts but rather a single unit of functionality. Consider the following example:
Verify user can sign up on the website
The above test case contains multiple testable parts which can further be subdivided as :

  • Verify user can sign up by entering valid data in the fields
  • Verify user can sign up using Facebook
  • Verify user can sign up using twitter
  • Verify user can sign up using google

For any kind of queries, suggestions and feedback, please feel free to contact me on my email address nidasaleem333@gmail.com

--

--