Writing good tests

What is a test?

A test is a deliberate action or experiment to find out how well something works

Google Dictionary

The take away here is “find out“.

Therefore testing is not “just checking” rather it involves critical and creative thinking. It is finding out more about something and learning from it.

When testing, information in returned. This information could help decide the best course of action. We write good tests so that the information returned will be useful.

What is a good test?

  • A good test is clear of its intent
  • A good test is easy to understand
  • A good test is easy to follow

Ideally, a test should answer the why, what and how.

Also, tests should short. It is recommended to test only one expected result so that it would be more deterministic.

What is a test case

Test cases are conditions in a given scenario.

In other words, it is a story- a beginning, middle and end.

This goes well with Gherkin and Arrange-Act-Assert pattern.

Test cases when done right, become specifications for the product.

How to write a test case

  1. Analyze the given scenario
  2. Think of conditions and expected results as test ideas.
  3. Write a test idea in this format WHEN/IF some condition or action, THEN expected result as a test case title.
  4. Think of the steps to achieve the expected result.

Ideally the test case title should be enough as a test. If it passes “what is a good test” criteria, then it should be approved.

For standardization purposes, TDD/BDD style is used to writing tests cases. This way it is formatted in a way that is easy to code for automation.


Manual test case

Scenario: Payment optionsTest Case Title: When pay at hotel option, user should receive a pay at hotel confirmationTest Steps:
1. Book a room
2. Click pay at hotel option
3. User should receive a pay at hotel confirmation

Automated test case


describe('Payment options', function() {
it('When pay at hotel option, user should receive a pay at hotel confirmation', function () {
Expect("Pay at Hotel Confirmation")===PayAtHotelPage().text();

Robot framework

*** Settings ***
Documentation     A test suite for payment options
...               As a user I should be able to pay with different payment options.
Library           SeleniumLibrary

*** Test Cases ***
When pay at hotel option, user should receive a pay at hotel confirmation
    Book a room
    Click pay at hotel option
    User should receive a pay at hotel confirmation

Test Case Review

Reviews are essential to have good test cases. It is also part of the QA process.

Always ask for 2 peer reviewers and have it approved. Ideally a peer reviewer with technical background and another with business background.

This makes sure that all aspects are covered. More so, they can suggest more test ideas or improve the test cases.

Things to look for during peer review

  • Follows “What is a good test?”
  • Follows the recommended format of “WHEN/IF some condition or action, expected result as a test case title.”
  • Grammar, spelling and typo

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s