Write Test Cases like a Pro

Tips and tricks to write foolproof, meaningful and effective test cases for any software.

Test case writing is one of the first steps of a testing cycle, and is crucial for any project. Any mistake in the creation of test cases proliferates through the entire testing process, and severely impacts the quality and delivery time of the project launch. Hence, test case writing must be approached with a proactive mindset, a good understanding of the feature/software, and a passion to make it all pristine.

A test case is defined as a test scenario measuring functionality across a set of actions or conditions to verify the expected result. They apply to any software application, can be for manual or automated testing, and are used in test case management tools as well. Test cases guide the testers through the sequence of steps to validate whether the software application is free of bugs, and is working as required by the end-users. In short, test cases form the base of the testing process for any software application or system.

Here are foolproof tips on how write test cases effectively and efficiently:

Keep them simple but connected

Keep all the steps of any test case atomic and precise. Include the correct mapping to the expected results. Make sure they are integrated with the test plan and other test cases. Refer to other test cases, relevant artifacts, GUIs, etc. where and when required, but keep a balance. Do not make a tester move back and forth in the pile of documents for completing a single test scenario.

Be specific for the testers

Try not to leave the test data entirely on testers. Give them a range of inputs, especially where calculations are to be performed or the application’s behavior depends on inputs. This is because intentionally or unintentionally they may use the same test data again and again and some important test data might get ignored during the execution of Test Cases (TCs). Lastly, do mention which TCs are interdependent and/or batched.

Explore Testworthy for test cases and complete test management

Checklist to include essential elements

Make a checklist and ensure that every test case you write includes all essential elements, done the right way. Depending on your software and testing needs, your specific checklist may vary, but the following can be used as a template:
  • 1.  Test case has a strong title that is self-explanatory and describes the characteristic of the module.
  • 2.  Test case has a short description which is easy to understand and describes the TC’s goal.
  • 3.  Includes the steps to follow to achieve specific objectives.
  • 4.  Includes the preconditions that must be met prior to the test being executed, and assumptions if any.
  • 5.  Includes the expected results that describe what should be the results of the test steps.
  • 6.  Includes the actual results that describe how the test is behaving by following the mentioned steps.
  • 7.  Includes the test result Pass/Fail against the particular test case.
  • 8.  Ensure the test case is measurable so that at the end of the test run, you can conclude whether the test passed or not.
  • 9.  The test case is unique for the scenario you are writing for, but is specific to a particular function.
  • 10.  The test case generates the same results every time no matter who tests it.
  • 11.  UseTraceability Matrix to ensure no functions/conditions are left untested.
  • 12.  Self-cleaning: Every test case must return the Test Environment to the pre-test state and should not render the test environment unusable. This is especially true for configuration testing.

Review your test cases and get them reviewed (peer review)

Once you are done with writing the last test case of a test scenario, go to the start and review all the TCs with the mindset of a tester. Think rationally and try to dry run your TCs. Evaluate all the steps and see if you have mentioned them clearly and the expected results are in harmony with the steps. Ensure that the test data specified in TCs is according to the real-time environment too. Verify that all references to other TCs, artifacts or GUIs are accurate. Also, get them reviewed by your colleagues. Your peers can uncover defects in your test case design, which you may have missed.

Remember the end user is the most important stakeholder

The most important stakeholder is the ‘End User’ who will finally use the application. So never forget them at any stage of TC writing. Keep yourself in the shoes of the End User and then go through all the TCs and judge the practical value of executing all your documented TCs.

Lastly, as a true QA person, try to contribute to business and give suggestions if you feel that something can be improved in the application. You do not have to accept the FS or Design document as it is. As a QA person, your aim should be to not just test, but also make a difference!

Get in touch with the Testworthy team to improve, automate, and optimize your testing efforts.