Learn How To Write Test Cases Effectively

By 31st October 2012 October 10th, 2019 Testing

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.

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 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.

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

 

Suggestions for further reading

 

Join 60,000+ Subscribers

For latest blogs, industry updates and exclusive tips.

*Your email is safe with us, we also hate spam

Join the discussion 15 Comments

  • 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/

  • 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

  • didi says:

    illuminating

  • Dan Ashby says:

    Here’s some good reading material on what’s included in testing when compared to checking:

  • praveen says:

    Useful information on writing test cases. Check out our blog on how bad bug reports will affect project costs

  • Hubert Jason says:

    Nice blog Mark. It is a very informative blog for new as well as experienced.

  • renee says:

    Interesting site.

  • 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

  • tushar says:

    Hi, thank you for this post I agree with you that When testers report defects based on the test case, they should indicate which test step failed, in order to make troubleshooting easier. very useful information

  • Hello,I log on to your new stuff named “How to write effective test cases” daily.Your writing style is witty, keep it up! And you can look our website about fast proxy list.

  • 86Susanna says:

    I see you don’t monetize your site, don’t waste your traffic,
    you can earn additional cash every month because you’ve got high quality content.
    If you want to know how to make extra money, search for:
    best adsense alternative Wrastain’s tools

  • banking says:

    Hi it’s me, I am also visiting this site on a regular basis,
    this web page is truly good and the people are actually
    sharing nice thoughts.

  • Ketozol says:

    Just wanna comment that you have a very nice website, I
    the style it really stands out.

  • bitco insera says:

    Some genuinely interesting information, well written and loosely user genial.

  • NuRadiance Lift Review says:

    Hi there outstanding blog! Does running a blog such as this
    take a large amount of work? I have virtually no knowledge of coding but I was hoping to start my own blog in the near future.
    Anyhow, if you have any recommendations or tips for new blog owners please share.
    I know this is off subject but I simply needed to ask. Thank you!

Leave a Reply