How To Write Test cases

There are certain documents which should be developed before and during software testing. This is known as Testing Documentation. This section describes Test Case Documentation.

What is a Test Case?

A test case is a set of actions which a tester carries out to verify a particular functionality of a software application. This helps to ensure that the software is bug free and end-user requirements are fulfilled. Usually, the QA team is responsible for writing test cases except unit test cases which are written by the development team.

Good test cases should be

  • Simple
  • Ensure 100% coverage
  • Avoid repetition
  • Repeatable

Why do we need Test Cases in Software Testing?

The main purpose of writing test cases is to verify that all features of a software application are working as expected. Other benefits of having test cases include;

  • Ensure that software meets the end user requirements
  • Improve quality of software
  • Anyone can refer and execute the test
  • Reduce maintenance and software support cost

How to write a Test Case in Software Testing?

Before writing a test case you should consider following facts.

  • Check whether the test case already exists. If yes, update it.
  • Consider all the different scenarios possible.
  • Give yourself enough time to write test cases.

Steps to write test cases

  1. Test case ID - A test case should have ID so that it can be identified easily.
  2. Test case description - This tells what the tester is going to test in brief.
  3. Test steps - This is about how to execute the test. Test steps should be clear, brief and include essential facts.
  4. Test data - In order to execute the test case, the tester would need Test Data.
  5. Expected result - This helps tester what is the perfect behaviour of the test case.
  6. Actual result - This includes the actual behaviour while the test cases were being executed.
  7. Status of the test - After check the actual result against expected result, assign Pass or Fail status
  8. Comments - Here the tester can include any useful information such as issues, attachments etc.

Here’s a sample test case for checking login functionality. Both positive and negative test cases should be included in testing.

Test Cases Best Practices

  • Write test cases such that others can understand easily and modify if required.
  • Create test cases keeping in mind the end user perspective.
  • Write unique test cases and avoid irrelevant and duplicate test cases.
  • Use testing techniques.
  • Use correct test case ID.

Conclusion

As a part of Test Documentation, Test Cases play an important role. Finally, writing test cases is nothing but you must have best practices.