How to write test cases with a sample test case



What is a test case?

A Test Case is a set of actions executed to verify a particular feature or functionality of your software application. The Test case has a set test data, precondition, certain expected and actual results developed for a specific test scenario to verify any requirement.


Why test cases are important?

  • Test cases ensure good coverage
  • Test cases are reusable
  • Once written, anyone can execute it
  • If there are no other documents, test cases can be used as baseline documents
  • It's easy to trace the history of pass/fail rate of the particular feature
  • Overall, it helps to improve the quality of the product

Who will use test cases?

Manual testers, automation testers, developers and management


What is a good test case?

A good test case or a well-written test case should allow any tester to understand and execute the test


How to write a good test case?

The main idea is to keep test cases simple, precise, reusable, to focus on one goal and not too big (7-8 steps maximum).


Important points/tips - 

  • Test case Id: Test rail by default generates this id.
  • Test case name/title: I prefer starting the title/test case name with the module name. For e.x. If we are writing login page related test cases, test case name should be “Login - Verify that the user is able to login with valid credentials”. It is okay to omit “Login - ” if the tool we are using gives the good distinction of test cases feature-wise.
  • Test case description: This should communicate the goal of the test case.
  • Preconditions: Preconditions section can refer to another test case if it is relevant. If we have any assumptions we can put it in the precondition section.
  • Test steps: Test steps will have 2 parts - step description and expected results. Step description is basically the action tester has to perform. The expected result is what you are expecting from that step.
  • Other details: Like section, type, priority, estimate, references and automation field has to be filled accordingly.


Sample test case -

Test case title Login - Verify that the user is able to login with a valid user name and valid password

Test case description This is to verify that a registered user is able to login to the system successfully after entering a valid user name and valid password.

PreConditions/Assumptions Registered user’s credentials are available

Test Steps | Expected Result

  1. Navigate to the website under site | Website URL is retrieved
  2. Enter registered user’s valid username | User name is visible
  3. Enter registered user’s valid password | Password is hidden
  4. Click sign-in | Upon sign in dashboard shall be loaded successfully

Comments