What is a test case?

  • 16th October 2019

Testing documentation (or artifacts) are of huge importance to any successful testing effort. Not only do they fulfil the requirement of having a written account of your overall testing process for future reference. But in the instance of test cases, they will provide you with steps for future reference, thus making them available for additional members of your team to execute, or in the case of a well-written test case, reuse in future testing.

But what makes a good test case? And how do you write one in such a way that anyone can understand and follow?

Test case 101

A test case is a set of written steps, the expected outcome and the actual outcome of a single test that has been derived from the user requirements of the AUT (application under test).

Test cases are (mostly) written by software testers with to help guide their testing of a particular feature. Essentially, you can think of a single test case as a list of step-by-step instructions to achieve an expected result which can be positive, or negative in its outcome.

What should be included in a test case?

A test case should be compiled using the following information at a minimum:

  • Title
  • Description
  • Steps to completed
  • Expected outcome
  • Actual outcome (to be completed once the test case has been executed)

It is also a good idea to include details of any prerequisites for your test case such as any test data to be present before execution. This can be as a reference to a previous test case for example instead of including multiple additional steps for the reader to follow. As this can make your test case unnecessarily complex and difficult for developers to investigate if there is an issue with one of the steps.

Do you have an example of a test case?

As mentioned above, test cases are derived from the requirements of the application being developed. So if we take the example of a website in which there is a login box that logs you in if you provide valid credentials. A test case for this feature might look like the below.

An example of a test case
An example of a test case

As you can see, the title, description, steps to complete the test and the expected outcome are all clear, easy to understand and are to the point. This is very important in writing a test case as there can be no room for interpretation by the person reading it.

For example, in the test steps section. You should list out the steps as specific as you can and try not to leave things for the user figure out for themselves.

The following is an example of a bad test case.

An example of a badly written test case
An example of a badly written test case

If you are not clear on the expected outcomes or the steps required to successfully run your test. Seek further clarification first before authoring your test case as this will make things much easier when it comes time to execute it.

Test cases can and will change

Once you have written a test case. Go back over it with a critical eye and ask yourself the following questions.

  • Is it clear?
  • Does it make sense?
  • Does it leave you with any questions about it’s intended purpose?

You should also from time to time go back and review older test cases. The world of software is constantly evolving. Existing functionality is prone to modification as the requirements are updated, and thus your test cases should also be revisited and updated over time to ensure they’re still effective.

Details of any changes made can be logged in a database, or online management tool if you are organizing your test cases in that way. But also a simple table in front of your test case is just as effective.

Example of a test case revision log
Example of a test case revision log

When are test cases used?

Test cases are utilized when the AUT is ready for the testing process to begin after the development of a certain feature. They should be prepared ahead of time using the requirements document where possible so that once development is complete. Testing can begin its process immediately.

A well-written test case can also be used as the basis for a bug report for the development team if an issue is discovered in one of the steps of your test cases that leads to unexpected results or causes another kind of unexpected error, or defect.

Conclusion

We have seen what goes into writing an effective test case.
They should be short in their step numbers and use clear and easy to understand language that ensures the end-user can follow it without difficulty.

A well-written test case can lead to better quality software and better understanding within the testing team.

Leave a Reply

Your email address will not be published. Please mark all required fields.