Learn How To Write Test Cases Effectively (2024)

Test case writing is an important part of software testing process and it is important to write test cases effectively in order to make your testing successful. So how to write test cases effectively?

There are lots of different ways to write test cases. This article will give you examples of common structures which you can use and adapt to suit your need.

Test Case Template

A test case is the set of steps that need to be done in order to test a specific function of the software. They are developed for various scenarios so that testers can determine whether the software is working the way it should and producing the expected results.

The test case should include its number, a description, the test data, expected result, actual result and status (whether the test passed or failed).

Here is a simple test case template with an example:

Test Case No.DescriptionTest DataExpected ResultActual ResultStatus (pass/fail)
#1Verify response when a valid email address and password is used(Email address and password details)Successful loginSuccessful loginPass

Your test could also include any pre-conditions or assumptions that are necessary for the test to be successful, such as the user must already be registered with the software.

A simple template for test cases

This is a fairly common structure that contains a number of important points. The test case has multiple test steps, some of which have expected result and some which do not.

You should have 3-8 test steps in a test case. If you only have a few test steps, you should probably consider making a checklist instead – it’s not worth your while to keep track of a lot of small test cases when a checklist will do the job just as well.

Learn How To Write Test Cases Effectively (1)

When testers report defects based on the test case, they should indicate which test step failed, in order to make troubleshooting easier.

When you write a test case, you don’t need to specify the expected result for each test step if the result is obvious. In the above example there are unnecessary outcomes of several test steps. For example, ff the browser doesn’t open, the tester won’t be able to proceed to the next step.

If your test case has too many test steps you ought to think about breaking up the test case into a set of smaller ones. If the test case contains a long list of test steps, and an error occurs, the developer will have to backtrack and repeat all the test steps, which he or she might not do by accident, or out of laziness.

Having too many test steps can be a disadvantage for the tester, too. The tester may have to repeat each one of the test steps to ensure that the bug is fixed.

Sometimes the test case template contains a field for pre-conditions. In practice only a few of the test cases need them, so the field is often left empty. An example of a pre-condition is that to change the customer’s address you have to enter a customer first. You can use this field to reference to other test cases, for example by entering a test case ID here.

Test cases are often grouped in test runs. A test run is simply a collection of test cases that testers should perform in a particular order. Rather that inserting pre-conditions into each test case, you could put them in the beginning of a test run instead. An example of pre-condition for a bunch of test cases could be to put the system in a certain state, for example, loading a certain set of customers into the system before testing begins.

Test Case Examples

Here is an example of a software test case:

Title: Login Page – Authenticate user on Hotmail.com

Description:A user should be able to log in athotmail.com.

Precondition:The user must have an email address and password that is previously registered.

Assumption:The browser supportshotmail.com

Test Steps:

  1. Navigate tohotmail.com
  2. Enter the email address of the registered user in the ’email’ field.
  3. Enter the password of the registered user
  4. Click the ‘Next’ button.
  5. Click ‘Log in’

Expected Result:The Hotmail inbox of the user should load.

Referencing test data

If you put your test data in a separate file and reference it from the test case, you’ll be able to use a single test case to test many different variations of the data. This is a better solution than explicitly stating test data in the test case.

Learn How To Write Test Cases Effectively (2)

A test data file can be created in Excel, in Notepad, or included in a database. In the test case above, the “Testaccounts.txt” file might consist of one column for the user name and one for the password. Each line in the test data file represents a unique combination of inputs. The test case will be very efficient because only one test case is needed to test multiple combinations. It also means that the choice of which test data to use is not just left up to the tester’s discretion.

More technical test cases

More technical test cases, such as system level testing, may refer to tests of the database or other system components.

Learn How To Write Test Cases Effectively (3)

Suggestions for further reading

  • Read our article on “How to develop a template for test cases” and which is also on our site – https://reqtest.com/blog/newsletters/how-to-develop-a-template-for-test-cases/
  • If you’re still writing test cases in Word, we highly recommend you look into real testing tools instead, such as ReQtest. See www.reqtest.com for more information.
  • Now that you’re using ReQtest, read these two articles, one about How to create test cases in ReQtest – https://reqtest.com/blog/howto/how-to-create-test-cases-in-reqtest/ and the other about how to and execute test cases in ReQtest – https://reqtest.com/blog/howto/plan-and-execute-test-cases-in-reqtest/
Learn How To Write Test Cases Effectively (2024)

FAQs

How to write test cases effectively? ›

How to write test cases: A step-by-step guide
  1. Define the area you want to cover from the test scenario.
  2. Ensure the test case is easy for testers to understand and execute.
  3. Understand and apply relevant test designs.
  4. Use a unique test case ID.
  5. Use the requirements traceability matrix in testing for visibility.
Mar 29, 2024

How many test cases can be written in a day? ›

Ans) Around 35 – 60 test cases you can execute per day.

Is writing test cases easy? ›

Writing test cases takes time. Consequently, if the system under test changes, you don't want to spend too much extra time updating them. Maintaining existing test cases should be as simple as possible – especially if you're not the test case author.

What is a good test case example? ›

An Example: Test Case Description: Test for Logging Into the application Given: A valid username and password for the web application When: User enters the username and password in the login page Then: the user should be able to log in to the application successfully.

How do you practice test cases? ›

Best Practices for Writing Test Cases
  1. Prioritize clarity and transparency. ...
  2. Focus on End-User requirements when writing sample test cases. ...
  3. Avoid repetition. ...
  4. Keep Test Steps as minimal as possible. ...
  5. Focus on achieving maximum test coverage. ...
  6. Create self-cleaning test cases.
May 9, 2024

What is the most important thing in a test case? ›

Ensure that the test case optimally covers all the verification points. The test steps should contain the data and information on how to perform the test. This is the most fundamental part of a test case. Keep this section clear, and don't leave out any necessary details.

What is the test case technique? ›

In this technique, the input domain of the software is divided into different equivalence classes, where each class represents a group of inputs that should behave similarly. Test cases are then designed to cover at least one representative from each equivalence class.

What is test case strategy? ›

A Test Strategy is a high-level document that outlines the approach, scope, objectives, and methods for testing a software application. It provides a framework for planning and executing testing activities throughout the software development lifecycle.

How long should it take to write a test case? ›

Not too long or too short

Test suits should be defined so they take between 45 and 90 minutes to run, while still covering a significant area of the system in ”one swoop”.

How to write test case manually? ›

How to write test cases with examples
  1. Create the test case description. ...
  2. Add necessary test data. ...
  3. Activate test steps. ...
  4. Check and document results. ...
  5. Add pre-conditions and post-conditions. ...
  6. Use simple test language. ...
  7. Test programming for end-user goals. ...
  8. Repeat tests infrequently.
Oct 23, 2023

What is a typical test case template? ›

A test case template is a predefined structure that provides a standardized way to document and create test cases. We have provided them as guidelines for testers to ensure that all necessary information about a test scenario is captured consistently across different test cases.

Which tool is best for writing test cases? ›

TestRail was specifically designed to make writing and organizing test cases as easy as possible. Everything you need is right there, all you have to do is fill in the details: preconditions, test instructions, expected results; you can even set priorities, and effort estimates.

How to write test cases professionally? ›

Then you'll want to follow these steps.
  1. Describe Your Test Case Scenario. The first step is to define what it is you want to cover. ...
  2. Identify the Preconditions of the Test Case. ...
  3. Plan the Test Case Steps. ...
  4. Define the Expected Results. ...
  5. Document the Actual Results of the Test Case.
Oct 26, 2023

How to write performance test cases? ›

How to Do Performance Testing?
  1. Identify the Test Environment. Identify the testing environment, production environment, and tools required for testing. ...
  2. Select Performance Testing Tools. ...
  3. Define Performance Metrics. ...
  4. Plan and Design Tests. ...
  5. Create a Test Environment. ...
  6. Execute the Tests. ...
  7. Resolve and Reset.
Mar 27, 2024

What are the factors you consider while writing test cases? ›

For preparing the right test case, a tester should consider the following factors:
  • Positive.
  • Negative.
  • User Interface.
  • Usability.
  • Performance.
  • Security.
  • Reliability.
  • Compatibility.
Jul 28, 2016

Top Articles
Latest Posts
Article information

Author: Eusebia Nader

Last Updated:

Views: 6621

Rating: 5 / 5 (60 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Eusebia Nader

Birthday: 1994-11-11

Address: Apt. 721 977 Ebert Meadows, Jereville, GA 73618-6603

Phone: +2316203969400

Job: International Farming Consultant

Hobby: Reading, Photography, Shooting, Singing, Magic, Kayaking, Mushroom hunting

Introduction: My name is Eusebia Nader, I am a encouraging, brainy, lively, nice, famous, healthy, clever person who loves writing and wants to share my knowledge and understanding with you.