How to Write a Good Test Case

How to Write a Good Test Case

  1. Write the test case:

    1. Please frame your test case in the following format to help us fix this more quickly:

      1. Scenario:

      2. Given I

      3. When I

      4. Then I

    2. Example:

      1. Scenario: The login form allows existing logged out user to log in

      2. Given I am a user with an active Open edX account that is logged out

      3. When I navigate to the landing page and click the login button

      4. Then I am directed to a login form

      5. And when I fill in the required fields of the login form with my correct account information and click the login button

      6. Then I am able to login to Open edX, I am directed to the My Courses page, and I see my account name towards the top of the page

  2. Review your test case and consider: does the test case need more detailed setup instructions?

    1. Using the example above, I could go above and beyond and provide the URL for the landing page where they should conduct the test, and make sure to reiterate that I should be logged out of the sandbox to perform this test. 

    2. Using the example above, I might add the following Setup instructions:

      1. Ensure that you’re logged out of the testing sandbox

      2. Navigate to: /

  3. Review your test case and consider: does the test case need to be re-written/expanded? Have you only considered the best-case-scenario or the “happy path”?

    1. Using the example above, I might update the test case to the following (underlined portion has been added):

      1. Scenario: The login form allows existing logged out user to log in

      2. Given I am a user with an active Open edX account that is logged out

      3. When I navigate to the landing page and click the login button

      4. Then I am directed to a login form

      5. And when I fill in the required fields of the login form with my correct account information and click the login button

      6. Then I am able to login to Open edX, I am directed to the My Courses page, and I see my account name towards the top of the page

      7. And when I… log out, navigate back to the login from and fill in the required fields of the login form with my correct username and the incorrect password and click the login button

      8. Then I see an error message at the top of the form and I am not able to log in

      9. And when I… log out, navigate back to the login from and fill in the required fields of the login form with the incorrect username and the correct password and click the login button

      10. Then I see an error message at the top of the form and I am not able to log in