Learn How To Write Effective Test Cases

by Ulf Eriksson / 31 October 2012 / 9 comments

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.

 

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.

Click Here To Create Your First Test Case Example in ReQtest & Become a Test Manager Pro (Free 10-Day Trial)

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 effective test cases

 

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.

 Click Here To Create Your First Test Case Example in ReQtest & Become a Test Manager Pro (Free 10-Day Trial)

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 effective test cases

 

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 effective test cases

 

Click Here To Create Your First Test Case Example in ReQtest & Become a Test Manager Pro (Free 10-Day Trial)

 

Suggestions for further reading

 

About the author: Ulf Eriksson

Ulf Eriksson

Ulf is the founder of ReQtest and as the Product Owner, decides what features are added to the product, and makes sure that ReQtest is of a consistently high quality. Ulf has written several books and courses as well as a library of articles on the subjects of testing and requirements management, as well as speaking publicly on a number of subjects related to the world of testing.

9 Comments

  1. [...] me to better understand the scope of the project and I was now fully armed and ready to start writing my test cases. Crisis averted. Whoop [...]

  2. Great list of tips Mark – I have also tried to come up with a similar list… and tried to pen down the top 13 tips – do check it out… http://quicksoftwaretesting.com/test-case-writing-tips/

  3. amanda says:

    These are some great tips for writing test cases! We have also written a blog post about test cases, which includes templates for starting. Check it out here! bit.ly/1CbHEhL

  4. praveen says:

    Useful information on writing test cases. Check out our blog on how bad bug reports will affect project costs – http://www.indiumsoft.com/Blog/how-bad-bug-reports-can-increase-project-cost/

  5. Hubert Jason says:

    Nice blog Mark. It is a very informative blog for new as well as experienced..
    http://www.janbask.net/8-essential-factors-for-a-qa-project-success/

  6. renee says:

    Interesting site.

  7. Cosette Kamakian says:

    Hi
    I’m new as a testmanager and we have a system which is dynamic. We create a questionnaire and my problem is that i can’t cut off on the teststeps because they need to be a part of the follow. For the moment I have 80 steps and I’m still not done . I know that it is too many steps. My question is how do i create a testcase in this situation

    Thank you for your help
    Cosette

Leave a Reply to praveen Cancel reply

Your email address will not be published. Required fields are marked *