How To Write Test Cases? Detailed Guide With Examples

April 26, 2026 · 10 min read · Testing Guide

Blog / Insights /
How To Write Test Cases? Detailed Guide With Examples

How To Write Test Cases? Detailed Guide With Examples

Contributors Updated on

Learn with AI

Linkedin

Facebook

X (Twitter)

Mail

Learn with AI

A test case is the backbone of any testing project.

The key to efficient package screen is not just how you pen test cases, but what scenarios you prefer to cover. Once the right test event are created, they should be closely aligned with the overall tryout design and exam execution strategy to ensure comprehensive and efficient testing.

Let ’ s explore how to write examination case in the most strategical fashion.

What is a Test Case?

A test case is a specific set of conditions or variables under which a tester determines whether a scheme, software application, or one of its features is work as intended.

Here ’ s an example. You are testing the Login pop-up of Etsy, one of the leading E-commerce platforms currently. You ’ ll need several test cases to check if all features of this page are working smoothly.

Brainstorming clip: & nbsp; what sport do you want to essay for this Login pop-up?

Let ’ s listing down some of them:

  1. Verify Login with Valid Credentials
  2. Verify Login with Invalid Credentials
  3. Verify `` Forgot Password '' Functionality
  4. Verify `` Trouble Signing In '' Link
  5. Verify `` Continue with Google '' Functionality
  6. Verify `` Continue with Facebook '' Functionality
  7. Verify `` Continue with Apple '' Functionality
  8. Verify `` Register '' Button Redirect
  9. Verify Empty Email Field Handling
  10. Verify Empty Password Field Handling
  11. Verify Error Message for Unregistered Email
  12. Verify Session Timeout Handling
     

That ’ s just a fast and immediate listing. As a issue of fact, the more complex a system is, the more test case are needed.

 

Learn More:100+ Test Cases For The Login Page That You Will Need

Components of a Test Case

A test case usually includes:

  1. Test Case ID– A unequalled identifier for tracking the test case.
  2. Test Description– A abbreviated summary of what the test will verify.
  3. Preconditions– The required setup or conditions before the test can be run.
  4. Test Steps– A list of actions to do during the examination.
  5. Expected Result– The outcome the system should produce if it works right.
  6. Real Result– The result observed during testing.
  7. Status– Whether the test passed, failed, or is still in progress.
  8. Comments/Notes– Any extra observations or details about the test.

Test Case Template Example

Here is an exemplar of a login 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 watchword.

3. Click the `` Sign In '' push.

Test Data

Emailvaliduser @ example.com

Password: validpassword123

Expected Result

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

Genuine Result

(To be filled in after executing)

Postconditions

User is logged in and the session is fighting

Pass/Fail Criteria

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

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

Comments

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

Best Practices When Writing a Test Case

Make sure to follow the following practices when compose your test example:

Component

Best Practices

Test Case ID

1. Use a consistent naming rule.

2. Ensure IDs are singular.

3. Use a prefix show the module/feature.

4. Keep it little but descriptive.

5. Maintain a central repository for all test case IDs.

Description

1. Be concise and clear.

2. Clearly province the determination of the examination.

3. Make it perceivable for anyone reading the tryout event.

4. Include the expected demeanour or outcome.

For autonomous testing across multiple user personas, check out SUSATest — it explores your app like 10 different real users.

5. Avoid proficient lingo and equivocalness.

Preconditions

1. Clearly specify setup essential.

2. Ensure all necessary conditions are met.

3. Include relevant system or environment states.

4. Detail any specific user part or configurations needed.

5. Verify stipulation before test performance.

Test Steps

1. Number each step sequentially.

2. Write steps distinctly and simply.

3. Use consistent terminology and activeness.

4. Ensure steps are reproducible.

5. Avoid combining multiple actions into one pace.

Test Data

1. Use naturalistic and valid datum.

2. Clearly specify each piece of test datum.

3. Avoid hardcoding sensitive information.

4. Utilize data-driven testing for scalability.

5. Store test data separately from exam scripts.

Expected Result

1. Be specific and open about the outcome.

2. Include UI changes, redirects, and messages.

3. Align with the acceptance criteria.

4. Cover all aspects of the functionality be tested.

5. Make consequence mensurable and discernible.

Actual Result

1. Document the actual outcome during execution.

2. Provide elaborate information on discrepancy.

3. Include screenshots or log if applicable.

4. Use coherent formatting for tape resultant.

5. Verify consequence against the expected outcomes.

Postconditions

1. Specify the expected scheme province post-test.

2. Include any necessary cleanup steps.

3. Ensure the system is stable for subsequent tests.

4. Verify that changes made during the test are reverted if demand.

5. Document any residual effects on the environment.

Pass/Fail Criteria

1. Clearly define pass/fail conditions.

2. Use mensurable and evident outcomes.

3. Ensure touchstone are objective.

4. Include specific error messages or behaviors for fails.

5. Align criteria with expected results and requirements.

Comments

1. Include additional helpful information.

2. Note assumptions, dependencies, or constraints.

3. Provide troubleshooting tips.

4. Record any deviations from the standard process.

5. Mention any special instructions for fulfil the trial.

Here are some more tips for you:

  1. Keep your test cases isolated in the sense that each test case should aim to test one specific instance of the scenario. This helps with your debugging later down the route.
  2. Leverage a test case direction schemethat syncs your test execution with test management and reporting.
  3. Conduct an explorative testing sessionfirst to gain a comprehensive savvy of the system you are testing. This facilitate you know what test cases to work on.
  4. Leverage the Gherkin format (Given, When, Then) and theBDD test methodologyto simplify test scenario into human decipherable language so other stakeholders can join in the conversation.

How To Write an Automation Test Script?

Writing manual test cases is primarily about note down the test steps. & nbsp;

When it comes to automation testing, the process becomes more complicated.

If you choose manual examination, you merely get to execute them following the precise steps as plan. If you go with automation examination, first you necessitate to opt whether you ’ ll go with a fabric or a testing tool.
 

Simply put:

1. Write a test case in Selenium

Install Selenium if you haven ’ t already:

 

pip install selenium

The steps we will encrypt include:

  1. Set up Chrome to run in headless modality (no GUI). This is whole optional.
  2. Initialize WebDriver
  3. Use “ driver.get (url) ” to open the Etsy login page
  4. Locate the web elements using its ID and XPath
  5. Enter certificate
  6. Submit the form
  7. Check condition

 

Here ’ s your handwriting:

Python
Explain

|

Contributors
The Katalon Team is composed of a diverse grouping of consecrated professionals, include subject thing expert with deep domain noesis, experienced technical writers skilled, and QA specialists who bring a practical, real-world view. Together, they give to the Katalon Blog, present high-quality, insightful articles that endue users to do the most of Katalon ’ s tools and stay updated on the latest trends in test automation and software quality.

Automate This With SUSA

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.

Try SUSA Free

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free