How To Write Test Cases? Detailed Guide With Examples
How To Write Test Cases? Detailed Guide With Examples
ContributorsUpdated 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:
Verify Login with Valid Credentials
Verify Login with Invalid Credentials
Verify `` Forgot Password '' Functionality
Verify `` Trouble Signing In '' Link
Verify `` Continue with Google '' Functionality
Verify `` Continue with Facebook '' Functionality
Verify `` Continue with Apple '' Functionality
Verify `` Register '' Button Redirect
Verify Empty Email Field Handling
Verify Empty Password Field Handling
Verify Error Message for Unregistered Email
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.
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.
ExpectedResult
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:
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.
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.
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:
An automation testing frameworkrequires some technical expertness and coding skills. Your job is essentially to write a playscript to automate all activity that you would differently feature done manually.
Set up Chrome to run in headless modality (no GUI). This is whole optional.
Initialize WebDriver
Use “ driver.get (url) ” to open the Etsy login page
Locate the web elements using its ID and XPath
Enter certificate
Submit the form
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.