Blog

13 September, 2017

Top Tips for Writing a Great Test Case

Having well written test cases (sometimes referred to as test scripts or test requirements) is vital in ensuring that testing is as efficient and effective as possible.

First of all, what is a test case?

The definition of a test case in the ISTQB Handbook is: “A set of input values, execution preconditions, expected results and execution postconditions, developed for a particular objective or test condition, such as to exercise a particular program path or to verify compliance with a specific requirement.”

Below are our top 10 tips for writing a great test case:

1. Avoid Assumptions, Ask Questions - Understanding of the requirements is the first and one of the most important steps when writing test cases. If assumptions are made when analysing the requirements then testing can be ineffective and can result in wasted time and effort. It is a good idea to create a question log and ask as many questions as needed to clarify any misleading or ambiguous statements in the documentation.

2. Ensure Requirement Traceability - Create a requirements matrix prior to the start of scripting or take advantage of test tools such as Application Lifecycle Management (ALM) that enable you to link requirements to test cases. Tracking requirements from test case writing, execution to completion can help to ensure all the requirements have been covered during testing.

3. Keep it Simple - Do not use overcomplicated language or test case structure. Use an agreed template or format, which will typically include the following information: Descriptive test case ID, a description/purpose or aim of the test, identify test data required, prerequisites/pre-conditions, then the test steps to be performed, and the expected results and results. The actual results, including whether the test passed or failed will be recorded when the test is performed.

4. Think about your Audience - Who is going to be executing the test case? What knowledge do they have of the system? This will dictate how much detail is required. If unsure, it is better to be specific and not assume prior knowledge of the system. This is especially important if the test cases will be re-used by someone else for future testing.

Employee Satisfaction Survey Image 4

5. Keep it Short and to the Point - As important as it is to give detail, too many steps can overcomplicate and slow down testing. If possible, break larger tests down into small ones. If a test fails you don’t want to have to repeat 50 steps to re-test the bug.

6. Don’t be Vague - Unclear language and long test steps can overcomplicate performing the test. Make sure your test cases are clear and easy to understand.

7. Be organised -  Group your tests logically by functionality, priority (run high priority test cases first then move onto the lower priority test cases) or group them according to pre-conditions (such as dependencies or set up required for a specific group of tests).

8. Allow for Reusability - The test cases should be adaptable for later releases and should be updated to reflect any software changes. This can save time and effort in future projects.

9. Keep the System User in Mind - What are the typical user journeys and end to end business flows? When writing test cases, considering the perspective of the end user ensures that real life scenarios and customer requirements are covered during testing.

10. Review objectively - If possible having another Tester review your test script can be a great way of ensuring that the steps are specific and easy to understand. If this is not possible, try to adopt the mindset of the person executing the test and read the test steps objectively.

In conclusion, following the above tips gives you the best chance to maximise the effectiveness of your test case writing.

 

By Gillian Galloway and Cecile Robb - Test Analysts, Edge Testing

Back to Blog