In this tutorial, you will learn how to write test cases. In addition, we will explore an advanced artificial intelligence-based test automation tool of the future that alleviates manual testing- which could tend to yield more human errors, be more time consuming, and potentially be more costly.

“The key takeaway while learning how to write test cases is to ensure they are well written so any tester can understand them can execute them.”

Before we learn how to write test cases, we must ensure we are on the same page with the various test industry terminology:

What is a Test Case?

In software development, a test case is a set of detailed instructions to test the software application ensuring it works properly for end-users. A test case includes test steps, testing data (such as login details,) an expected result upon successful execution, as well as unexpected results if there are failures. For example, a test case may include a set of instructions to test the login feature of an application.

Traditionally, it has been known for QA teams to document test cases in spreadsheets, but this can be rather cumbersome especially at scale. Other teams have resorted to project management software. There are some excelling with test management software such as TestRail.

What is a Test Script?

A test script is a set of commands or steps designed to test a system or application. Most DevOps teams currently require scripts to be programmed (or written) in programming languages they are familiar with such as Java, C#, Python, JavaScript, or Ruby.

This raises the barrier for entry to test automation engineers- which are in low supply. It also makes it harder for non-engineering testers to integrate as they often lack programming skills. Thus creating a shortage problem.

There is a shift, however, towards requiring testers to write test scripts with the aid of record-and-playback software. Our software, Autify, makes testing easy for anyone on the team using our GUI rather than coding. Instead of writing test scripts in a programming language, our codeless platform writes the coded steps for users. Therefore, a tester would only need to focus on interaction with the browsers. Engineers can focus on coding new features. Autify’s machine learning algorithms also handles maintenance too. We have witnessed the lack of maintenance at scale be the downfall of other testing software.

What is a Test Scenario?

A test scenario is a group of steps that are part of the large test case picture. Basically, it is any function or feature in the software that can be tested. For example, testing a login screen, testing images display properly or testing an ‘Add to Cart’ button on an e-commerce store.

The above screenshot is from modern test automation software. It showcases a visual dashboard of each step in the scenario versus manual data entries in a spreadsheet. More important, any step in the scenario can be modified. They can be re-record without recreating the entire scenario from scratch.

What is a Test Plan?

A test plan is a strategic document detailing specific objectives, resources, schedules, processes, estimation, and deliverables in software testing. Think of it as the holistic plan of attack when testing. It can detail who is responsible for certain tasks, the testing environment(s), and more. It can include various testing methodologies such as Unit, System, Acceptance, and Regression testing.

How to Write Test Cases?

A test case typically consists of the below elements. By using this as a sample guide, it will ensure a tester in any skill level can follow up on test cases:

    • Test Case ID – a unique identifier of the test case.
    • Test Description – a description of the test objective.
    • Test Steps – enter each step needed to complete the test case.
    • Test Data – all necessary testing data needed (if applicable.) In our example below, we included email addresses and password data.
    • Expected Results – the desired result output for the test case.
    • Test Result – Pass or Fail result.

Notes – any additional notes, useful for the current or future tester(s).

Below is a sample test case usually housed in a spreadsheet…

Other notable columns can include Pre-conditions and Post-conditions. In the example above, we can expand a pre-condition as logging as an admin user. I.e. testing an application on Firefox. With Autify, testers can test across multiple browsers and devices including desktops and mobiles. A post-condition example can be a date and timestamp of the login test.

In a modern QA team, the best way to write test cases is to automate them. Especially for repetitive tasks. No code test automation tools like Autify extend beyond repetitious tasks, however. It features a learning engine to detect changes in the UI. This is important in ever-changing software development environments. Instead of a tester wasting time investigating why a test failed, and re-running tests. Autify adapts to the change and points out the anomaly to the tester in a side-by-side comparison screenshot.

Conclusion

The key takeaway while learning how to write test cases is to ensure they are well written so any tester can understand them can execute them. As the case writer, imagine yourself in someone else’s shoes. It is important to provide as much information about tests as possible. Be transparent, avoid assumptions, and aim for making tests reusable rather than having to rewrite them. I hope this guide helped in creating great test scripts!