Effective Test Case Creation

Test Case is a commonly used term for a specific test. This is usually the smallest unit of testing. A Test Case will consist of information such as requirements testing, test steps, verification steps, prerequisites, outputs, test environment, etc. It’s a huge task to write effective cases with all the relevant details.

Test Case – Definition

“A Test Case is a set of inputs, execution preconditions, and expected outcomes developed for a particular objective, such as to exercise a particular program path or to verify compliance with a specific requirement.”

Often people have a misconception in the terms, test cases and test scripts, or even test suite. Many people use them interchangeably, and that is a mistake. In short, a test script (or test suite) is a compilation of multiple test cases.

Approach to Test Case Writing

Organizations take a variety of approaches to documenting test cases; these range from developing detailed, recipe-like steps to writing general descriptions. In detailed test cases, the steps describe exactly how to perform the test. In descriptive test cases, the tester decides at the time of the test how to perform the test and what data to use.

When planning your tests, remember that it is not feasible to test everything. Instead of trying to test every combination, prioritize your testing so that you perform the most important tests — those that focus on areas that present the greatest risk or have the greatest probability of occurring first.

Guidelines to Prepare a Test Case

Implementing the design techniques, every tester needs to keep in mind general guidelines that will aid in test case design. Take a look at the below general guidelines:

  • The purpose of each test case is to run the test in the simplest way possible.
  • Concentrate initially on positive testing i.e. the test case should show that the software does what it is intended to do.
  • Existing test cases should be enhanced and further test cases should be designed to show that the software does not do anything that it is not specified to do i.e. Negative Testing
  • Where appropriate, test cases should be designed to address issues such as performance, safety requirements and security requirements.
  • Further test cases can then be added to the unit test specification to achieve specific test coverage objectives. Once coverage tests have been designed, the test procedure can be developed and the tests executed.

Tips for writing a Good Test Case

  • Tests only one thing – Always make sure that your test case tests only one thing, if you try to test multiple conditions in one test case it becomes very difficult to track results and errors.
  • Organize your test cases consistently – You can organize your test cases in many ways however you should always follow the same pattern to organize you test cases.
  • Write independent test cases – Your test cases should not have dependency on other test cases, i.e. you should be able to execute your test case individually without having dependency on other test cases.
  • Let your test cases be small. Always mention purpose of each test case clearly in test case.
  • The objective of the test case should never include the expected result of the test case. You can include the conditions.
  • You can write the pre-conditions at global level (if applicable to all the test cases) or at the test case level (if applicable to individual test case) only.
  • The expected result should be written as a result of the last test step.
  • Use the correct template for writing the test cases

Test Case Writing Procedure

  • Study the application
  • Standardize an approach for test case writing
  • Identify sets of test cases
  • Decide on a structure

The main objective of the test case is to ensure the testing coverage of the application. As a tester, the best way to determine the compliance of the software to requirements is by designing effective test cases that provide a thorough test of a unit. Various test case design techniques enable the testers to develop effective test cases. The usefulness of the cases will depend how relevant they are so Test Cases should be Effective and Good.