How to Write Test Cases for Automation Testing?

how to write test cases for automation testing
Key takeaways
The 30-second version of this article
Automation test cases are scripted instructions that simulate user behavior and check the outcome, defining preconditions, test steps, expected results, and actual results.
You can't copy manual test cases straight into a script. Write them for automation from the start, with minimal UI dependency, clear assertions, and isolated flows.
The best candidates for automation are tests that run often, need large datasets, take too long manually, or must run across multiple platforms and environments.
A complete automation test case includes an ID, description, preconditions, steps, test data, expected and actual results, pass/fail criteria, and optional postconditions.
Keep tests independent, clear, and stable. Use abstraction like the Page Object Model, reuse common flows such as login, and make failures easy to diagnose.

Test automation is about speed, scale, and precision. As software teams ship faster, the pressure on QA increases, but manual testing can’t keep up with that speed. You need a way to validate key workflows without slowing things down.

That’s where automation testing come in to save the day. With some good automation test cases, you are going to significantly speed up your testing and reduce release time.

In this guide, I am going to show you how to write test cases for automation testing, and the best practices for it.

Let's dive right in!

What is automation testing?

Test automation is the practice of running tests automatically, managing test data, and using the results to improve software quality. While it’s a core QA activity, its success depends on the entire software delivery team. From business analysts to developers and DevOps engineers, everyone plays a role in making automation effective.

By taking repetitive work off manual testers’ plates, automation frees them to focus on higher-value activities, like exploratory testing, analyzing results, and identifying edge cases. It’s essential for maximizing coverage, improving accuracy, and shortening overall testing cycles.

Before creating any automated test cases, it’s critical to identify which scenarios are truly worth automating. Ideal candidates include:

  • Tests that must run against multiple data sets
  • Tests that provide broad coverage of complex or end-to-end workflows
  • Tests that need to run across various hardware, software platforms, or environments
  • Tests that are time-consuming or labor-intensive to execute manually

What are automation test cases?

Automation test cases are scripted instructions that simulate user behavior and validate the outcome. They define four things:

  • Preconditions: What must be true before the test runs (e.g. user logged in, database seeded)
  • Test Steps: The sequence of interactions to simulate (e.g. fill form, click submit)
  • Expected Results: What the system should do (e.g. show success message, redirect to dashboard)
  • Actual Results: What actually happened when the script ran

But here’s the nuance: you can’t just copy-paste your manual test cases into a script. Automation has different constraints. It needs to be stable, repeatable, and code-aware.

Manual testers rely on intuition. Automation relies on clarity. So test cases must be purpose-built with automation in mind, i.e. minimal UI dependency, clear assertions, isolated flows.

📚 Read More: 9 Core Benefits of Test Automation

What types of test cases should be automated?

Yes, automation testing is awesome, but not all tests can be automated. It’s all about “automation feasibility”.

So, what makes a test case feasible for automation? There are several:

  • Tests that need to be run frequently and repeatedly
  • Tests that require large datasets and many iterations
  • Tests that take too long or just tedious when done manually
  • Tests requiring execution on multiple hardware and software platforms

Why writing good automation test cases matters

Good automation test cases pay off in every sprint. Here’s why:

  • Faster regression cycles: What used to take days now runs in hours, or even less.
  • Consistent results: No more human error. The same steps, the same checks, every time.
  • Scalability: Run the same test across browsers, devices, and environments.
  • Team velocity: QA shifts from bottleneck to accelerator. Developers get feedback faster, and bugs are caught earlier.

But automation should not be seen as a silver bullet. The value comes from choosing the right things to automate, not trying to automate everything.

💡 Pro tip: Focus on flows that are stable, high-impact, and repeatable. Skip anything that’s volatile or hard to assert.

Key elements of an automation test case

Automation thrives on clarity. Every test case should include the following:

  • Test Case ID: A unique identifier used to track and reference the test case.
  • Description: A short, specific, action-oriented statement that clearly summarizes what is being tested.
  • Preconditions: Conditions or system state that must be met before the test can be executed.
  • Test Steps: A step-by-step list of actions to perform during the test.
  • Test Data: Specific input values required for executing the test case.
  • Expected Result: The system’s expected behavior or output based on the test steps.
  • Actual Result: The actual behavior or output observed during test execution.
  • Postconditions: The system state after the test completes (optional but helpful for chaining tests).
  • Pass/Fail Criteria: The specific conditions that determine whether the test has passed or failed.

For example, here's an example of a test case for the Etsy login popup:

Component

Details

Test Case ID

TC001

Description

Verify Login with Valid Credentials

Preconditions

User is on the Etsy login popup

Test Steps

1. Enter a valid email address.

2. Enter the corresponding valid password.

3. Click the "Sign In" button.

Test Data

Email: validuser@example.com

Password: validpassword123

Expected Result

Users should be successfully logged in and redirected to the homepage or the previously intended page.

Actual Result

(To be filled in after execution)

Postconditions

User is logged in and the session is active

Pass/Fail Criteria

Pass: Test passes if the user is logged in and redirected correctly.

Fail: Test fails if an error message is displayed or the user is not logged in.

Comments

Ensure the test environment has network access and the server is operational.

Best practices when writing automated test cases

  • Write independent test cases – Each test should run on its own without depending on another test’s outcome. This makes debugging easier and reduces flaky failures.
  • Keep tests clear and concise – Use descriptive names and straightforward logic so anyone on the team can understand what a test is validating. Readability = maintainability.
  • Focus on stability – Avoid brittle selectors, unnecessary waits, or overly complex steps. Stable tests produce reliable results and reduce false failures.
  • Use proper abstraction (like Page Object Model) – Separating test logic from UI elements or data keeps your tests cleaner and easier to update when something changes.
  • Reuse common functions or components – Login flows, setup steps, and repeated interactions should be centralized. Reusability saves time and reduces duplicated code.
  • Make failures easy to diagnose – Provide clear assertions, helpful logs, screenshots, or error messages so the root cause of a failure is immediately visible.

Conclusion

Test automation is about building trust in your product at scale. A good automation test case is clear, reliable, and purpose-built. It validates what matters, runs consistently, and delivers fast feedback to your team. But it only works if you automate the right things: stable flows, repeatable tasks, and system-critical behaviors.

Manual testing catches edge cases. Automation holds the line.

With the right framework, the right test cases, and the right balance, you don’t have to choose between speed and quality. You can deliver both, confidently, at every release.

banner8 (1

Frequently asked questions

Huyen Nguyen
Huyen NguyenTechnical Writer, Katalon

Huyen Nguyen is an experienced technical writer in the software testing industry. With strong technical expertise and a deep understanding of Katalon products, she creates clear, practical guides that support testers at every skill level.

Connect on LinkedIn →
Get started

Test everything. Ship with confidence.

From generating test cases to spotting failures, Katalon's AI works across your entire pipeline, automatically.

The Next Evolution of Manual Testing: Introducing Katalon AI Test Runner

Introducing Katalon AI Test Runner. Watch it run manual test cases live, with evidence for every pass and fail.

Live webinar
9:00 to 10:00 AM EST · Live online
Alex MartinsVP of Strategy
Gia EspositoSenior Solutions Engineer
Save your seat