Guides › Software Testing & QA
How to Write Test Cases: Examples and Templates
Learn how to write effective software test cases with step-by-step examples, test case templates, testing techniques, real-world scenarios, and best practices.
How to Write Test Cases: Examples and Templates
Writing effective test cases is one of the most important skills in software testing and quality assurance (QA). Well-written test cases help testers verify application functionality, identify defects, maintain test coverage, and ensure that software behaves according to requirements.
A good test case explains what needs to be tested, what conditions are required, which steps must be followed, and what result should be expected.
In this complete guide, you will learn how to write test cases step by step, understand different test case types, use reusable templates, apply test design techniques, and practice with real-world examples.
Table of Contents
- What Is a Test Case?
- Why Are Test Cases Important?
- Test Case vs Test Scenario vs Test Script
- Anatomy of a Test Case
- How to Write Test Cases Step by Step
- Test Case Template
- Types of Test Cases
- Test Case Writing Techniques
- Real-World Test Case Examples
- Test Cases for Login Functionality
- Test Cases for Registration
- Test Cases for Search Functionality
- Test Cases for Shopping Cart
- Test Cases for API Testing
- Positive and Negative Test Cases
- Test Case Prioritization
- Test Coverage and Traceability
- Common Test Case Writing Mistakes
- Test Case Review Checklist
- Test Case Management Tools
- Practical Exercises with Solutions
- Interview Questions and Answers
- Frequently Asked Questions
- Conclusion
1. What Is a Test Case?
A test case is a documented set of preconditions, inputs, execution steps, and expected results used to verify a specific behavior of an application.
Test cases help testers determine whether a feature works as intended.
Example
Suppose you are testing the login functionality of a website.
Test Case ID: LOGIN-001
Title: Verify login with valid credentials
Preconditions: An active registered user account exists.
Test Data: Valid email address and password.
Steps:
- Open the login page.
- Enter the registered email address.
- Enter the correct password.
- Click the Login button.
Expected Result: The user should successfully log in and reach the dashboard.
Actual Result: Recorded after execution.
Status: Not Run.
This test case verifies one specific condition: whether a user can log in using valid credentials.
Key Characteristics of a Good Test Case
A good test case should be:
- Clear and easy to understand.
- Focused on a specific behavior.
- Repeatable by another tester.
- Linked to a requirement when appropriate.
- Supported by suitable test data.
- Associated with a measurable expected result.
- Easy to maintain when requirements change.
2. Why Are Test Cases Important?
Test cases provide a systematic approach to verifying software functionality.
2.1 Improve Test Coverage
Test cases help ensure that important requirements, workflows, and error conditions are tested.
2.2 Make Testing Repeatable
Different testers can follow the same instructions and compare results consistently.
2.3 Find Defects Earlier
Well-designed cases cover normal behavior, invalid inputs, boundary values, and unusual conditions.
2.4 Support Regression Testing
Existing test cases can be executed again after code changes to check whether previously working features still function correctly.
2.5 Improve Team Communication
Test cases provide a shared understanding of what must be verified and what results are expected.
2.6 Help with Audits and Reporting
In projects that require formal records, test cases and execution results can provide evidence of testing activities.
2.7 Support Automation
Suitable manual test cases can later be converted into automated tests when the expected behavior is stable and automation provides value.
3. Test Case vs Test Scenario vs Test Script
These terms are related but are not interchangeable.
Test Scenario
A high-level description of something that needs testing.
Example: Verify login functionality.
Test Case
Detailed steps, inputs, preconditions, and expected results used to test a particular condition.
Example: Verify that login succeeds with valid credentials.
Test Script
Instructions or executable code used to perform a test. The term often refers to an automated script, although some teams also use it for manual execution instructions.
Example: A Playwright script that opens the login page, enters credentials, and checks whether the dashboard appears.
| Feature | Test Scenario | Test Case | Test Script |
|---|---|---|---|
| Purpose | Identify what to test | Define how to verify a condition | Execute or describe test actions |
| Detail | High-level | Detailed | Manual instructions or executable code |
| Example | Test login | Login with valid credentials | Automated login check |
| Typical use | Planning coverage | Manual or automated test design | Test execution |
One scenario may require multiple test cases.
4. Anatomy of a Test Case
A test case usually contains several fields. The exact format depends on the organization and testing tool.
4.1 Test Case ID
A unique identifier for tracking a test case.
Example: LOGIN-001.
4.2 Test Case Title
A short description of the condition being verified.
Example: Verify login with valid credentials.
4.3 Requirement ID
The identifier of the requirement associated with the test case.
Example: REQ-LOGIN-001.
4.4 Preconditions
Conditions that must be satisfied before the test begins.
Example: The test account is registered and active.
4.5 Test Data
The inputs used during execution.
Example: A valid test email and an approved test password.
Avoid storing real passwords or secrets directly in shared test documentation.
4.6 Test Steps
The sequence of actions the tester must perform.
Example:
- Open the login page.
- Enter the test email.
- Enter the test password.
- Click Login.
4.7 Expected Result
The behavior that should occur.
Example: The user reaches the dashboard.
Expected results should be specific enough to evaluate objectively.
4.8 Actual Result
The behavior observed during execution.
This field is filled in after the test runs.
4.9 Status
Common values include:
- Not Run
- Pass
- Fail
- Blocked
- Not Applicable
A team may define additional statuses.
4.10 Priority
Indicates how important the test case is to execute.
Example: High, Medium, or Low.
Priority is not the same as defect severity.
4.11 Test Type
Identifies the testing category.
Examples: Functional, Regression, Security, Compatibility, or Usability.
4.12 Environment
Records where the test was performed.
Example: Staging environment, supported browser, application build version.
4.13 Evidence and Comments
Screenshots, logs, notes, or other relevant information that supports the execution result.
5. How to Write Test Cases Step by Step
Follow this workflow to create clear and useful test cases.
Step 1: Understand the Requirements
Read the user story, product specification, acceptance criteria, and relevant design documents.
Identify:
- What the feature should do.
- Who can use it.
- Which inputs are accepted.
- Which inputs must be rejected.
- What errors should be displayed.
- What happens in unusual situations.
Example requirement:
"A registered user can log in using a valid email address and password."
Before writing cases, clarify relevant questions such as what happens to inactive accounts or repeated failed login attempts.
Step 2: Identify Test Scenarios
Break the feature into high-level behaviors.
For login functionality, possible scenarios include:
- Successful login.
- Incorrect password.
- Unregistered email.
- Empty required fields.
- Invalid email format.
- Password visibility.
- Logout.
- Session expiration.
- Access to protected pages.
Step 3: Define Preconditions
Determine what must be ready before the test executes.
Examples:
- The application is available.
- A registered test account exists.
- The account is active.
- The tester has the correct permissions.
- Required test data is available.
Step 4: Select Test Data
Choose representative data for each scenario.
For a login form, data may include:
- Valid credentials.
- Incorrect password.
- Unknown email.
- Empty values.
- Invalid email format.
- Inputs containing leading or trailing spaces.
Use controlled test accounts and avoid using real user credentials.
Step 5: Write Clear Test Steps
Write each action in the order it should be performed.
Poor step: "Check login."
Better steps:
- Open the login page.
- Enter a registered email address.
- Enter the correct password.
- Click Login.
Each step should describe an observable action.
Step 6: Define Expected Results
Describe the correct outcome for the tested condition.
Weak expected result: "It should work."
Better expected result: "The application authenticates the test user and displays the account dashboard."
For a failed login, specify that authentication is rejected and the application displays the appropriate error state without exposing sensitive details.
Step 7: Assign IDs and Priorities
Use a consistent naming convention.
Examples:
- LOGIN-001
- LOGIN-002
- REG-001
- CART-001
- SEARCH-001
Prioritize cases based on business impact, likelihood of failure, usage frequency, and risk.
Step 8: Review Test Cases
Check that:
- The steps are understandable.
- Preconditions are complete.
- Test data is suitable.
- Expected results are measurable.
- Important negative and boundary cases are covered.
- Cases are not unnecessarily duplicated.
Step 9: Execute and Record Results
Run the test cases and record the actual result.
Mark a case as Pass only when the observed behavior meets the expected result.
If a test cannot be executed because the environment is unavailable, record it as Blocked according to the team's process.
Step 10: Maintain Test Cases
Update test cases when requirements, workflows, interfaces, or business rules change.
Remove obsolete cases carefully and preserve execution history where required.
6. Test Case Template
Use the following template for manual testing projects.
Simple Test Case Template
| Field | Description |
|---|---|
| Test Case ID | Unique test identifier |
| Title | Behavior being tested |
| Requirement ID | Related requirement |
| Preconditions | Conditions required before execution |
| Test Data | Inputs used |
| Steps | Actions performed |
| Expected Result | Correct expected behavior |
| Actual Result | Observed behavior |
| Status | Pass, Fail, Blocked, or Not Run |
| Priority | Execution importance |
| Environment | Browser, device, build, or environment |
| Evidence | Screenshot, logs, or comments |
Copyable Test Case Format
Test Case ID: [Unique ID]
Title: [Short test case title]
Requirement ID: [Related requirement]
Preconditions: [Conditions required before execution]
Test Data: [Input data]
Steps:
- [First action]
- [Second action]
- [Third action]
Expected Result: [Expected behavior]
Actual Result: [Fill after execution]
Status: Not Run
Priority: [High / Medium / Low]
Environment: [Environment and build]
Evidence: [Link or notes, if applicable]
Example of a Completed Test Case
Test Case ID: SEARCH-001
Title: Search for an existing product
Requirement ID: REQ-SEARCH-001
Preconditions: The application is available and the product exists in the catalog.
Test Data: A known product name.
Steps:
- Open the shopping website.
- Locate the search field.
- Enter the product name.
- Submit the search.
- Review the results.
Expected Result: Relevant matching products appear in the search results.
Actual Result: Fill in after execution.
Status: Not Run.
Priority: High.
7. Types of Test Cases
7.1 Functional Test Cases
Verify that a feature works according to its requirements.
Example: Adding a product to the cart updates the cart as specified.
7.2 Positive Test Cases
Verify expected behavior using valid inputs.
Example: A registered user logs in with correct credentials.
7.3 Negative Test Cases
Verify that invalid inputs or prohibited actions are handled correctly.
Example: Login with an incorrect password is rejected.
7.4 Boundary Test Cases
Check values at and around accepted limits.
Example: If an age field accepts 18 to 60 inclusive, test 17, 18, 19, 59, 60, and 61.
7.5 Validation Test Cases
Check required fields, formats, length limits, and other validation rules.
Example: A registration form rejects an invalid email format.
7.6 UI Test Cases
Check visual and interaction requirements.
Example: Verify that buttons are visible, labels are readable, and validation messages appear in the expected location.
7.7 Compatibility Test Cases
Check behavior across supported browsers, operating systems, and devices.
7.8 Security Test Cases
Check security requirements using authorized testing methods.
Examples include verifying access controls, session handling, and safe error messages.
Security testing should follow the project's authorization and scope.
7.9 Performance Test Cases
Verify performance requirements under defined conditions.
Example: Measure whether a product search meets its agreed response-time target under a specified workload.
7.10 Regression Test Cases
Verify that existing functionality still works after a change.
Example: After updating checkout, verify that cart totals and order confirmation still work.
7.11 Integration Test Cases
Verify interactions between connected components or services.
Example: Confirm that a successful payment result updates the order status correctly.
8. Test Case Writing Techniques
Test design techniques help testers select effective inputs and conditions without creating unnecessary test cases.
8.1 Equivalence Partitioning
Equivalence partitioning divides inputs into groups expected to behave similarly.
Suppose an age field accepts values from 18 to 60 inclusive.
Possible partitions:
- Below 18: Invalid.
- From 18 to 60: Valid.
- Above 60: Invalid.
Representative values could be 16, 35, and 65.
The technique reduces the number of inputs that need to be tested while preserving useful coverage.
8.2 Boundary Value Analysis
Boundary Value Analysis focuses on values at and around the limits.
For an inclusive range of 18 to 60, test:
- 17
- 18
- 19
- 59
- 60
- 61
Boundary checks are useful because errors often occur at limits.
8.3 Decision Table Testing
Decision tables are useful when behavior depends on multiple conditions.
Example: A discount applies only when a customer is eligible and the order total meets the minimum amount.
| Customer Eligible | Minimum Order Met | Expected Discount |
|---|---|---|
| Yes | Yes | Applied |
| Yes | No | Not applied |
| No | Yes | Not applied |
| No | No | Not applied |
Each row represents a condition combination that should be verified.
8.4 State Transition Testing
This technique checks how an application moves between states.
Example: An account may move between Active, Locked, and Unlocked states based on login behavior and account recovery rules.
Test the allowed transitions and verify that prohibited transitions are rejected.
8.5 Use Case Testing
This technique verifies complete user workflows.
Example:
- Log in.
- Search for a product.
- Add the product to the cart.
- Complete checkout using an approved test payment method.
- Verify the order confirmation.
8.6 Error Guessing
Based on experience, testers anticipate areas where defects may occur.
Examples:
- Repeatedly clicking Submit.
- Refreshing a page during an operation.
- Entering very long strings.
- Using unusual but permitted characters.
- Navigating backward during checkout.
These ideas should supplement systematic test design rather than replace it.
9. Real-World Test Case Examples
Example A: Password Reset
Test Case ID: RESET-001
Title: Request password reset using a registered email.
Preconditions: An eligible test account exists.
Steps:
- Open the password-reset page.
- Enter the registered test email.
- Submit the form.
- Check the expected confirmation behavior.
Expected Result: The application follows the documented password-reset process and provides an appropriate confirmation.
Additional cases should verify invalid email input, rate limiting, expired reset links, already-used links, and successful password changes.
Example B: File Upload
Test Case ID: FILE-001
Title: Upload a supported file.
Preconditions: The user is authorized to upload files.
Steps:
- Open the upload form.
- Select a supported file within the size limit.
- Submit the upload.
- Verify the upload status.
Expected Result: The file is accepted and displayed according to the requirements.
Additional cases:
- Unsupported file type.
- File larger than the permitted size.
- Empty file, if relevant.
- Interrupted upload.
- Duplicate filename.
- Unauthorized upload attempt.
Example C: Coupon Code
Test Case ID: COUPON-001
Title: Apply a valid coupon to an eligible order.
Preconditions: A valid coupon and eligible test order exist.
Steps:
- Add eligible products to the cart.
- Open the checkout page.
- Enter the coupon code.
- Apply the coupon.
- Review the order summary.
Expected Result: The correct discount is applied according to the coupon rules.
Additional cases should cover expired coupons, minimum order values, excluded products, repeated use, and removal of an applied coupon.
10. Test Cases for Login Functionality
Login functionality is a common example for practicing test case design.
| Test Case ID | Test Condition | Expected Result |
|---|---|---|
| LOGIN-001 | Valid email and password | Login succeeds |
| LOGIN-002 | Incorrect password | Login is rejected |
| LOGIN-003 | Unregistered email | Authentication is rejected |
| LOGIN-004 | Empty email | Required-field handling appears |
| LOGIN-005 | Empty password | Required-field handling appears |
| LOGIN-006 | Invalid email format | Input is validated according to requirements |
| LOGIN-007 | Leading or trailing spaces | Input is handled according to defined rules |
| LOGIN-008 | Password visibility toggle | Password visibility changes as specified |
| LOGIN-009 | Logout | Session ends as specified |
| LOGIN-010 | Access protected page after logout | Access is denied or login is required |
| LOGIN-011 | Session expiration | Reauthentication is required when appropriate |
| LOGIN-012 | Repeated failed login attempts | Security controls follow the requirements |
The exact behavior should match the application's requirements and security design.
11. Test Cases for Registration
A registration form may include name, email, password, password confirmation, and consent fields.
| Test Case ID | Test Condition | Expected Result |
|---|---|---|
| REG-001 | Valid registration details | Account is created according to requirements |
| REG-002 | Empty required fields | Validation appears |
| REG-003 | Invalid email | Email validation appears |
| REG-004 | Weak password | Password requirements are enforced |
| REG-005 | Password confirmation mismatch | Registration is rejected |
| REG-006 | Duplicate registered email | Duplicate-account behavior follows requirements |
| REG-007 | Missing required consent | Submission is rejected when consent is mandatory |
| REG-008 | Successful registration | Confirmation is shown |
| REG-009 | Email verification required | Verification flow works as specified |
| REG-010 | Refresh after submission | Duplicate account creation is prevented or handled correctly |
Also consider input length, permitted characters, accessibility, and privacy requirements.
12. Test Cases for Search Functionality
| Test Case ID | Test Condition | Expected Result |
|---|---|---|
| SEARCH-001 | Search for an existing product | Relevant results appear |
| SEARCH-002 | Search for a nonexistent product | Appropriate no-results state appears |
| SEARCH-003 | Submit an empty query | Behavior follows requirements |
| SEARCH-004 | Search using uppercase letters | Matching behavior follows requirements |
| SEARCH-005 | Search with leading or trailing spaces | Input is handled appropriately |
| SEARCH-006 | Search with special characters | Input is handled safely |
| SEARCH-007 | Apply a category filter | Results match the filter |
| SEARCH-008 | Sort results | Results follow the selected order |
| SEARCH-009 | Navigate between result pages | Results and page state remain consistent |
| SEARCH-010 | Search on a supported mobile device | Search remains usable |
Test search behavior against the application's actual matching and filtering rules.
13. Test Cases for Shopping Cart
| Test Case ID | Test Condition | Expected Result |
|---|---|---|
| CART-001 | Add an available product | Product appears in cart |
| CART-002 | Add the same product again | Quantity or cart behavior follows requirements |
| CART-003 | Increase quantity | Quantity and total update correctly |
| CART-004 | Decrease quantity | Quantity and total update correctly |
| CART-005 | Remove product | Product is removed |
| CART-006 | Apply valid coupon | Discount is calculated correctly |
| CART-007 | Apply invalid coupon | Appropriate message appears |
| CART-008 | Refresh cart page | Cart state behaves as specified |
| CART-009 | Product becomes unavailable | Checkout is prevented or updated appropriately |
| CART-010 | Proceed to checkout | Correct cart details appear |
Where relevant, verify rounding, tax, shipping, currency, and discount calculations.
14. Test Cases for API Testing
API test cases verify how a service behaves when it receives requests and returns responses.
Consider a product API endpoint that retrieves a product by ID.
Example API Test Case
Test Case ID: API-PRODUCT-001
Title: Retrieve an existing product.
Preconditions: The API test environment is available and the test product exists.
Request: Send the documented GET request to retrieve the product by its ID.
Expected Result:
- The response uses the documented success status.
- The response body contains the expected product fields.
- The product ID matches the requested ID.
- Data types and required fields follow the API contract.
Additional API Test Cases
- Valid resource ID.
- Nonexistent resource ID.
- Invalid resource ID format.
- Missing authentication.
- Insufficient permissions.
- Missing required request fields.
- Invalid request data.
- Rate limit behavior.
- Correct error response structure.
- Response time against an agreed performance target.
Use authorized test endpoints and test credentials. Never expose API secrets in test documentation.
15. Positive and Negative Test Cases
Positive and negative testing verify different aspects of application behavior.
Positive Testing
Uses valid inputs to verify that expected workflows succeed.
Example:
- Enter valid login credentials.
- Submit the form.
- Verify that the user reaches the dashboard.
Negative Testing
Uses invalid inputs or prohibited actions to verify that the application handles them correctly.
Example:
- Enter an incorrect password.
- Submit the form.
- Verify that login is rejected.
Comparison
| Feature | Positive Testing | Negative Testing |
|---|---|---|
| Inputs | Valid or expected | Invalid or prohibited |
| Objective | Verify successful behavior | Verify safe and correct failure handling |
| Login example | Correct credentials | Incorrect password |
| Registration example | Valid email | Invalid email format |
| API example | Valid request | Missing or invalid required data |
Both approaches are important for meaningful test coverage.
16. Test Case Prioritization
When time is limited, testers may not be able to execute every test case immediately.
Prioritization helps teams decide which cases should be executed first.
High Priority
Critical user journeys, major business functions, security-sensitive workflows, and features with high impact if they fail.
Examples:
- User authentication.
- Checkout and payment.
- Access control.
- Order creation.
Medium Priority
Important features whose failure affects a subset of users or has a reasonable workaround.
Examples:
- Product filtering.
- Profile editing.
- Saved preferences.
Low Priority
Lower-risk behavior with limited impact.
Examples:
- Minor visual issues in a noncritical area.
- Low-usage optional functionality.
Priority should be based on business impact, failure likelihood, usage, dependencies, and release risk.
17. Test Coverage and Traceability
Test coverage describes how much of the intended testing scope has been addressed.
Coverage can be measured against requirements, features, risks, workflows, or other project objectives.
Requirement Traceability Matrix
A Requirement Traceability Matrix (RTM) connects requirements to test cases.
| Requirement ID | Requirement | Test Case ID | Status |
|---|---|---|---|
| REQ-001 | Users can log in | LOGIN-001 | Pass |
| REQ-002 | Invalid passwords are rejected | LOGIN-002 | Pass |
| REQ-003 | Required fields are validated | LOGIN-004 | Fail |
| REQ-004 | Users can log out | LOGIN-009 | Not Run |
The RTM helps identify requirements with missing tests and cases that have not yet passed.
Simple Coverage Calculation
If 18 out of 20 identified requirements have at least one mapped test case:
Coverage = (18 ÷ 20) × 100 = 90%
This is a measure of requirement mapping, not proof that the software is 90% defect-free.
Test Execution Metrics
Teams may track:
- Total test cases.
- Executed test cases.
- Passed test cases.
- Failed test cases.
- Blocked test cases.
- Not-run test cases.
- Defects by severity.
- Requirements without adequate coverage.
Always define how metrics are calculated so reports are not misleading.
18. Common Test Case Writing Mistakes
Vague Test Steps
Problem: Another tester cannot reproduce the test.
Improvement: Write specific, ordered actions.
Unclear Expected Results
Problem: The tester cannot determine whether the case passed.
Improvement: Describe observable, measurable behavior.
Missing Preconditions
Problem: The test fails because the required account or data is not available.
Improvement: Document setup requirements.
Testing Only Valid Inputs
Problem: Invalid data and error handling remain untested.
Improvement: Include negative and boundary conditions.
Duplicate Test Cases
Problem: Repeated cases increase maintenance effort without adding meaningful coverage.
Improvement: Review whether each case verifies a distinct condition.
Missing Test Data
Problem: Testers cannot reproduce the scenario consistently.
Improvement: Specify controlled inputs and setup steps.
Overly Complicated Test Cases
Problem: A single case checks too many unrelated behaviors.
Improvement: Split complex cases into focused tests when doing so improves clarity and diagnosis.
Hard-Coded Sensitive Data
Problem: Credentials or personal data may be exposed.
Improvement: Use approved test accounts, secret-management mechanisms, and sanitized evidence.
Outdated Test Cases
Problem: Cases no longer match current requirements.
Improvement: Review and update tests when the application changes.
Marking Unexecuted Cases as Passed
Problem: Test reports become misleading.
Improvement: Record the actual execution status accurately.
19. Test Case Review Checklist
Before approving a test case, check the following:
- The title clearly describes the condition.
- The test case ID is unique.
- The related requirement is identified where applicable.
- Preconditions are documented.
- Test data is available.
- Steps are clear and ordered.
- Expected results are specific.
- Positive conditions are covered.
- Negative conditions are covered.
- Boundary values are considered.
- The case is not unnecessarily duplicated.
- Priority is appropriate.
- Sensitive information is excluded.
- Another tester can execute the case independently.
20. Test Case Management Tools
Test case management tools help teams organize cases, execute tests, and track coverage.
TestRail
Used to organize test cases, test runs, and execution reports.
Zephyr
Provides test management capabilities for teams using supported project management integrations.
Jira
Often used to track defects, tasks, and testing work through workflows and integrations.
Azure Test Plans
Supports test planning, test suites, and test execution within supported development workflows.
Spreadsheets
Useful for small projects that need a simple, low-overhead way to document cases and results.
How to Choose a Tool
Consider:
- Project size.
- Team workflow.
- Reporting needs.
- Integration requirements.
- Access control.
- Cost.
- Maintenance effort.
The best tool is the one that supports your team's testing process without adding unnecessary complexity.
21. Practical Exercises with Solutions
Exercise 1: Write a Login Test Case
Requirement: A registered user must be able to log in using valid credentials.
Suggested Solution:
Test Case ID: LOGIN-001
Title: Verify login with valid credentials.
Preconditions: An active test account exists.
Test Data: Valid test email and password.
Steps:
- Open the login page.
- Enter the test email.
- Enter the test password.
- Click Login.
Expected Result: The user reaches the dashboard.
Exercise 2: Test an Age Field
Requirement: An age field accepts values from 18 to 60 inclusive.
Which values should be tested?
Suggested Solution:
Test 17, 18, 19, 59, 60, and 61.
These values cover both boundaries and nearby values.
Exercise 3: Write Registration Test Cases
Requirement: Users must provide a valid email and a password that meets the application's rules.
Suggested Solution:
- Valid email and valid password — Registration proceeds.
- Invalid email format — Validation appears.
- Empty email — Required-field handling appears.
- Password below the required standard — Validation appears.
- Missing required fields — Submission is rejected.
- Existing email — Duplicate-account behavior follows requirements.
Exercise 4: Test a Coupon
Requirement: A coupon is valid only for eligible products and orders meeting the minimum total.
Suggested Solution:
Test:
- Eligible product and minimum total met.
- Eligible product but minimum total not met.
- Ineligible product and minimum total met.
- Expired coupon.
- Invalid coupon code.
- Coupon removed after being applied.
For each case, specify the expected discount and error behavior according to the requirements.
Exercise 5: Improve a Poor Test Case
Poor test case:
Title: Check search.
Steps: Open website and search.
Expected Result: It works.
Rewrite it.
Suggested Solution:
Test Case ID: SEARCH-001
Title: Verify search for an existing product.
Preconditions: The website is available and a known product exists.
Test Data: A valid product name.
Steps:
- Open the website.
- Locate the search field.
- Enter the product name.
- Submit the search.
Expected Result: Relevant matching products appear.
22. Interview Questions and Answers
Q1. What is a test case?
A test case is a documented set of preconditions, test data, steps, and expected results used to verify a particular behavior.
Q2. What makes a good test case?
It should be clear, repeatable, focused, traceable where appropriate, and have measurable expected results.
Q3. What is the difference between a test case and a test scenario?
A scenario describes what needs to be tested at a high level. A test case describes the specific steps and expected results used to verify a condition.
Q4. What are positive and negative test cases?
Positive cases verify expected behavior using valid inputs. Negative cases verify that invalid inputs and prohibited actions are handled correctly.
Q5. What is boundary value analysis?
It is a test design technique that focuses on values at and around the limits of an accepted range.
Q6. What is equivalence partitioning?
It divides input data into groups expected to behave similarly, allowing representative values to be selected from each group.
Q7. What is an RTM?
A Requirement Traceability Matrix maps requirements to test cases or other testing evidence to help assess coverage.
Q8. What is the difference between priority and severity?
Priority indicates how urgently an issue should be addressed. Severity describes the impact of the defect.
Q9. Can a test case be automated?
Yes. Suitable cases can be automated when the workflow is stable and automation provides sufficient value.
Q10. What should happen when a test case fails?
Verify the expected behavior, record the actual result, gather evidence, report the defect, and track it according to the team's workflow.
Q11. What is regression testing?
Regression testing checks whether changes have broken previously working functionality.
Q12. How do you prioritize test cases?
Consider business impact, failure likelihood, usage frequency, dependencies, security risk, and release deadlines.
23. Frequently Asked Questions
How many test cases should a feature have?
There is no fixed number. The number depends on complexity, requirements, risks, and the coverage needed.
Should every test case have a unique ID?
In a managed test suite, a stable unique identifier is strongly recommended because it helps with tracking, reporting, and traceability.
Should test cases include screenshots?
Screenshots are useful when they clarify setup or support an execution result. They are not required for every case.
Can one test case have multiple expected results?
Yes, but the expected results should remain clear and related. If several independent behaviors make the case difficult to diagnose, consider splitting it into separate cases.
Should test cases be written before coding?
They can be drafted during requirements and design work, then refined as the feature becomes clearer. Early test design can reveal missing or ambiguous requirements.
What is the difference between a test case and a checklist?
A test case usually contains detailed steps, data, and expected results. A checklist is generally a shorter list of conditions to verify.
How often should test cases be updated?
Update them whenever requirements, user flows, or expected behavior change. Review them regularly to remove obsolete or duplicate cases.
Is manual test case writing still useful when automation is available?
Yes. Clear test design helps establish what should be verified, whether execution is manual or automated.
24. Conclusion
Writing effective test cases is a core software testing skill. Strong test cases make testing more consistent, improve requirement coverage, help teams find defects, and provide reliable evidence about application behavior.
To improve your skills, start with simple features such as login, registration, and search. Write test scenarios, create detailed test cases, include negative and boundary conditions, and practice recording execution results.
As you gain experience, learn traceability, risk-based prioritization, API testing, and automation. These skills will help you develop a stronger foundation in software quality assurance.
Related Guides
- Software Testing: Complete Beginner to Advanced Guide
- Manual Testing: Complete Guide with Examples
- Software Testing Life Cycle (STLC): Complete Guide
- Bug Reporting and Defect Life Cycle
- Functional vs Non-Functional Testing
- Automation Testing: Complete Beginner Guide
More guides
- How to Use Codify: A 7-Day Start Plan — New here? Pick a roadmap, make a study plan, start the DSA sheet, revise with notes, practise for placements and test yourself — one step a day, then a daily routine.
- Infosys Preparation Guide: Online Test, Pseudocode and Interview — Roles (SE, DSE, SP), what each section of the Infosys online test checks, how to crack pseudocode and reasoning, a 4-week plan and the interview.
- Wipro Elite NLTH Preparation: Aptitude, Essay and Coding — The Wipro fresher test round by round — quant, logical and verbal, the written essay, two coding problems — plus a 3-week plan and interview tips.
- Accenture Preparation Guide: Cognitive, Technical, Coding and Communication — Every Accenture round explained — cognitive, MS Office/networking/cloud technical MCQs, pseudocode, coding and the spoken-English test — with a 4-week plan.