GUIDE / manual
Test Cases for Search Functionality
Practical test cases for search functionality: relevance, filters, no-results, typos, ranking, performance, and ecommerce search QA examples.
Good test cases for search functionality go far beyond typing a word and checking that a page reloads. Search is a product feature with ranking, relevance, indexing lag, filters, permissions, language behavior, and empty states. When search is weak, users cannot find value that already exists. When search is wrong, users lose trust in the catalog, knowledge base, or app content.
This guide gives you a complete approach to designing search test cases for websites and apps, including ecommerce, content portals, and SaaS record search. You will get scenario maps, sample cases, relevance golden sets, filter matrices, security checks, and prioritization guidance.
What Search Functionality Includes
A typical search system has multiple layers:
- Input box UX and validation.
- Query parsing and normalization.
- Retrieval against an index or database.
- Ranking and relevance logic.
- Filters, facets, and sort.
- Result rendering and pagination.
- No-result and error states.
- Analytics events.
- Permissions and visibility rules.
- Performance and resiliency.
If you only test layer 1 and 6, you will miss the expensive defects.
Clarify Search Requirements First
Before writing cases, answer:
- What entities are searchable (products, articles, users, orders)?
- Which fields are indexed (title, SKU, tags, body, metadata)?
- Is search exact, prefix, fuzzy, or boolean?
- Are synonyms supported?
- Is ranking personalized?
- How fresh is the index after catalog updates?
- Are results permission-filtered?
- Do filters use AND or OR semantics?
- Is the empty query allowed, blocked, or shows popular items?
- Are there language or locale specific analyzers?
Write unknowns as open questions. Search bugs often come from unspoken ranking assumptions. For general case writing structure, use how to write test cases.
Test Cases for Search Functionality: Scenario Map
Core retrieval scenarios
- Exact match on title.
- Exact match on ID/SKU.
- Partial token match.
- Multi-word query.
- Case variation.
- Extra whitespace.
- Leading/trailing spaces.
- Stop words if language analysis applies.
- Synonym match if configured.
- Obsolete or unpublished item exclusion.
UX scenarios
- Empty submit.
- Query at max length.
- Clear search control.
- Recent searches if present.
- Suggestions/autocomplete.
- Keyboard navigation through suggestions.
- Clicking a suggestion.
Zero and low result scenarios
- Truly unknown term.
- Misspelling with and without fuzzy matching.
- Valid term filtered to zero by facets.
- Query with only special characters.
Facet and sort scenarios
- Single filter.
- Multiple filters.
- Sort by price/relevance/newest.
- Filter then sort.
- Sort then filter.
- Clear all.
Authorization scenarios
- Public user does not see private docs.
- Role A does not see role B records.
- Logged-out vs logged-in result differences if intended.
Resilience scenarios
- Slow responses show loading state.
- Backend error shows recoverable message.
- Very long query handled safely.
Search Input Test Cases
Search starts as a text field. Reuse discipline from test cases for a text field, then add search-specific expectations.
| ID | Title | Input | Expected |
|---|---|---|---|
| TC-SEARCH-001 | Valid keyword returns results | wireless headphones | Relevant results rendered |
| TC-SEARCH-002 | Empty query behavior | blank submit | Blocked, popular items, or all-items per rule |
| TC-SEARCH-003 | Whitespace only | | Treated as empty per rule |
| TC-SEARCH-004 | Leading/trailing spaces | shoes | Same as shoes if trimmed |
| TC-SEARCH-005 | Case insensitivity | Shoes vs shoes | Equivalent results for normal catalog search |
| TC-SEARCH-006 | Max length query | exact max chars | Handled without crash |
| TC-SEARCH-007 | Over max length | max+1 | Rejected or truncated per rule |
| TC-SEARCH-008 | Special characters | C++, AT&T, #1 | Sensible matches or safe empty, no error page |
| TC-SEARCH-009 | SQL-like string | ' OR '1'='1 | No bypass, safe handling |
| TC-SEARCH-010 | XSS payload query | <script>alert(1)</script> | Escaped in UI, no execution |
Detailed example:
Test Case ID: TC-SEARCH-004
Title: Verify search trims outer spaces before querying
Priority: Medium
Preconditions: Catalog contains products matching "mug"
Test Data: " mug "
Steps:
1. Open page with search box.
2. Enter " mug ".
3. Submit search.
Expected Result:
- Results equivalent to query "mug".
- No zero-result solely due to spaces.
- Query display may show trimmed value.
Relevance and Ranking Test Cases
Returning results is not enough. The right results must rank well.
Build a golden query set
Create a table of business-critical queries:
| Query | Must appear in top N | Must not appear | Notes |
|---|---|---|---|
| exact product name | Top 3 | Discontinued SKU | Exact title boost |
| popular brand + category | Top 10 | Unrelated category | |
| SKU code | Top 1 | Exact ID lookup | |
| common synonym | Top 10 | e.g., sofa vs couch if synonymized | |
| competitor misspelling | Top 10 if fuzzy on | Optional |
| ID | Title | Expected |
|---|---|---|
| TC-SEARCH-020 | Exact title ranks high | Known product in top 3 |
| TC-SEARCH-021 | SKU exact match first | Exact SKU product is first |
| TC-SEARCH-022 | Synonym support | Configured synonym returns targets |
| TC-SEARCH-023 | Unpublished item excluded | Draft/hidden item not shown publicly |
| TC-SEARCH-024 | Out of stock ranking policy | Matches config (included/demoted/hidden) |
| TC-SEARCH-025 | Stop-word heavy query | Still returns useful matches if intended |
Relevance judgments should be reviewed with product and merchandising, not only QA opinion.
Partial Match, Tokenization, and Language Cases
| ID | Title | Example | Expected direction |
|---|---|---|---|
| TC-SEARCH-030 | Prefix match | head finds headphones if prefix enabled | Match policy |
| TC-SEARCH-031 | Multi-word all tokens | red running shoes | Results relate to combined intent |
| TC-SEARCH-032 | Word order variation | shoes running red | Acceptable if unordered tokens allowed |
| TC-SEARCH-033 | Hyphenation | t-shirt vs tshirt | Per analyzer rules |
| TC-SEARCH-034 | Accent insensitivity | cafe vs café | Equivalent if configured |
| TC-SEARCH-035 | Locale-specific analysis | language-specific stemming | Correct for selected locale |
Document analyzer expectations. Otherwise testers and developers argue endlessly about "should run match running?"
No Results and Recovery UX
| ID | Title | Expected |
|---|---|---|
| TC-SEARCH-040 | Unknown term empty state | Clear no-results message |
| TC-SEARCH-041 | Suggestions for likely typo | Did-you-mean if feature exists |
| TC-SEARCH-042 | Recommendations on empty | Labeled as popular/recommended, not as matches |
| TC-SEARCH-043 | Keep query visible | User can edit query easily |
| TC-SEARCH-044 | Zero results with active filters | Message indicates filters may be too narrow, easy clear |
Bad empty states look like broken pages. Good empty states recover conversion.
Autocomplete and Suggestions
If search has typeahead:
| ID | Title | Expected |
|---|---|---|
| TC-SEARCH-050 | Suggestions appear after threshold | Shows after N characters per rule |
| TC-SEARCH-051 | Keyboard navigate suggestions | Arrow keys move, enter selects |
| TC-SEARCH-052 | Mouse select suggestion | Navigates to result or fills query |
| TC-SEARCH-053 | Debounced requests | No excessive spam of API calls on every key (observability check) |
| TC-SEARCH-054 | Suggestion permission filter | No private titles leaked in suggestions |
| TC-SEARCH-055 | Esc closes suggestion list | Focus remains usable |
Filters, Facets, and Sort Matrices
Faceted search defects are common in ecommerce and catalog apps. For broader store coverage, pair with test cases for ecommerce website.
Single filter cases
| ID | Title | Expected |
|---|---|---|
| TC-SEARCH-060 | Filter by brand | Only that brand |
| TC-SEARCH-061 | Filter by price range | All visible items within range |
| TC-SEARCH-062 | Filter by rating | Matches threshold rule |
| TC-SEARCH-063 | Filter by availability | In-stock only if selected |
Combined filters
| ID | Title | Expected |
|---|---|---|
| TC-SEARCH-064 | Brand + size | AND semantics if that is the rule |
| TC-SEARCH-065 | Two values in same facet | OR within facet if standard ecom pattern |
| TC-SEARCH-066 | Conflicting filters to zero | Empty state, not error |
| TC-SEARCH-067 | Remove one filter | Results expand correctly |
| TC-SEARCH-068 | Clear all filters | Back to base query results |
Sort cases
| ID | Title | Expected |
|---|---|---|
| TC-SEARCH-070 | Sort price low to high | Non-decreasing prices |
| TC-SEARCH-071 | Sort price high to low | Non-increasing prices |
| TC-SEARCH-072 | Sort newest | Date order correct |
| TC-SEARCH-073 | Sort relevance default | Default selected on new query |
| TC-SEARCH-074 | Sort preserved with filter change | Per product design |
URL and shareability
If filter state is in the URL:
- Copy URL in new session restores same results.
- Back button restores previous filter state.
- Manual URL edit with invalid facet fails safely.
Pagination and Result Stability
| ID | Title | Expected |
|---|---|---|
| TC-SEARCH-080 | Page 2 loads next set | No duplicate of page 1 items |
| TC-SEARCH-081 | Last page partial fill | Renders remaining items |
| TC-SEARCH-082 | Infinite scroll load more | Appends without duplicates |
| TC-SEARCH-083 | Result count accuracy | Count matches policy (exact or approximate label) |
| TC-SEARCH-084 | Stable sort ties | Deterministic secondary key if required |
Unstable ordering makes automation flaky and users confused.
Index Freshness and Catalog Update Cases
Search quality depends on indexing.
| ID | Title | Expected |
|---|---|---|
| TC-SEARCH-090 | New product becomes searchable within SLA | Appears by promised time |
| TC-SEARCH-091 | Title update reflected | New title matches, old title behavior per design |
| TC-SEARCH-092 | Unpublished product disappears | Not returned after unpublish propagation |
| TC-SEARCH-093 | Price update reflected | Result card shows updated price after refresh SLA |
| TC-SEARCH-094 | Deleted product removed | No dead result links, or soft handling |
If SLA is 5 minutes, your expected result must include timing context. Immediate consistency is not always required, but it must be known.
Permissioned and Personalized Search
| ID | Title | Expected |
|---|---|---|
| TC-SEARCH-100 | Private document not in public search | Hidden |
| TC-SEARCH-101 | User finds own order by ID | Found for owner |
| TC-SEARCH-102 | User cannot find others' order by ID | Not found or denied |
| TC-SEARCH-103 | Personalized boost does not leak data | Only allowed items boosted |
| TC-SEARCH-104 | Admin search wider scope | Admin sees allowed operational fields only |
Authorization bugs in search are data breaches waiting to happen.
Performance and Resilience Cases
You may not run full load tests in a functional suite, but include smoke expectations.
| ID | Title | Expected |
|---|---|---|
| TC-SEARCH-110 | Common query responds within target | e.g., under agreed threshold on staging baseline |
| TC-SEARCH-111 | Loading indicator for slow query | User sees progress, can cancel if supported |
| TC-SEARCH-112 | Backend 500 handling | Friendly error, retry path |
| TC-SEARCH-113 | No results still fast | Empty state not a hang |
| TC-SEARCH-114 | Heavy facet combination | No crash, acceptable degradation |
Record environment notes. Performance assertions without baselines create arguments.
Analytics and Instrumentation Cases
If search metrics matter to the business:
- Search submitted event fires once.
- Zero result event fires on empty.
- Suggestion click tracked distinctly from manual submit.
- Filter applied events include facet ids.
Broken analytics make product teams fly blind even when UI works.
Special Domains
Ecommerce search extras
- Search by SKU, barcode, brand, category synonyms.
- Merchandising pins/boosts for campaigns.
- Exclude products not sellable in current region.
- Currency and catalog differences by market.
SaaS app record search extras
- Search operators (
from:,status:) if supported. - Saved searches.
- Recent records.
- Field-scoped search.
Help center / content search extras
- Heading vs body boosts.
- Locale-specific content only.
- Attachments searchable or not.
Boundary Ideas for Search Queries
From boundary value analysis and equivalence partitioning:
- 0 chars, 1 char, minimum suggestion threshold, max length, max+1.
- Single character queries if allowed (
a) can stress the system. - Multi-byte unicode characters counting toward max length.
- Extremely high page numbers (
page=999999).
| ID | Title | Expected |
|---|---|---|
| TC-SEARCH-120 | One character query | Per rule: blocked, suggestions, or broad results |
| TC-SEARCH-121 | Huge page number | Empty safe state or redirect to last page |
| TC-SEARCH-122 | Negative page number | Safe rejection |
Sample Golden Mini Suite
- Exact product/content title match ranks high.
- Case insensitive equivalence.
- Trimmed spaces equivalence.
- SKU/ID exact match.
- Unknown term empty state.
- XSS query escaped.
- Brand filter AND query works.
- Price sort ascending correct.
- Page 2 has no duplicates.
- Private item not visible to unauthorized user.
- New item searchable within SLA.
- Autocomplete keyboard selection works.
These twelve cases catch a surprising percentage of production search complaints.
Common Mistakes When Testing Search
Mistake 1: Checking only that results are non-empty
Irrelevant non-empty results are still failures.
Mistake 2: No golden set
Without expected top results, relevance debates never end.
Mistake 3: Ignoring filters after query
Most real users combine query + facets.
Mistake 4: Forgetting permissions
Search is an easy accidental data leak surface.
Mistake 5: Testing only perfect spelling
Users misspell constantly. If fuzzy is promised, test it. If not, confirm empty states are good.
Mistake 6: Unclear freshness expectations
Testers report bugs for index lag that is actually within SLA, or miss real stale index bugs.
Mistake 7: Flaky automation on personalized ranking
Personalization and A/B ranking need fixtures or else automation becomes noisy.
Mistake 8: No mobile search UX cases
Small screens hide suggestions, filters, and clear buttons differently.
Writing Strong Expected Results for Search
Weak:
Search works.
Stronger:
For query
blue ceramic mug, product SKU MUG-BLUE-01 appears in the top 3 results, all visible items contain blue or mug relevance signals per business rules, result prices match PDP for the same SKU, and result links open the correct PDP.
Include:
- What must appear.
- Where it should rank if critical.
- What must not appear.
- What the empty state should show.
- How filters alter the set.
Automation Strategy
Good automation candidates:
- Deterministic ID/SKU exact match.
- Case and trim normalization.
- Filter application with seeded catalog.
- Authz: private doc excluded.
- XSS escaped rendering smoke.
- Pagination duplicate checks on stable sort.
Harder to automate without help:
- Subjective relevance quality.
- Merchandising boosts that change weekly.
- Personalized results.
Use seeded indexes in test environments. Do not point relevance automation at a constantly changing production catalog without stable fixtures.
Practice Exercise
Pick a live public store or content site and in 45 minutes:
- List 15 real queries users would type.
- Mark expected first result for 5 of them.
- Execute those 5 and note ranking misses.
- Apply two filters and re-check counts.
- Force a no-results query and critique the empty state.
- Convert findings into 8 formal test cases.
For competitive practice writing tight scenarios quickly, use QABattle battles and then formalize your notes into a search suite.
Review Checklist
- Input normalization covered.
- Exact and partial match covered.
- Relevance golden queries exist for critical terms.
- Empty state covered.
- Filters and sort covered.
- Pagination stability covered.
- Permissions covered.
- Index freshness expectations documented.
- Security samples covered.
- Mobile and autocomplete covered if present.
- Analytics smoke considered if business critical.
- Priority labels match user impact.
Worked Example: Building a Search Suite for a Catalog App
Imagine a mid-size ecommerce catalog with 12,000 SKUs, brand and size facets, synonym support for a few merchandising terms, and a five-minute index lag SLA. Here is how a practical suite comes together in one afternoon.
Step 1: Write the search contract
Searchable fields: title, brand, SKU, category, top tags
Default sort: relevance
Facet semantics: AND across facets, OR within multi-select brand
Empty query: blocked with helper text
Fuzzy: on for edit distance 1 after 4 characters
Synonyms: sofa=couch, TV=television
Private drafts: excluded from public search
Index lag SLA: 5 minutes for publish/unpublish
Step 2: Seed known products
Create or identify fixtures:
| SKU | Title | Brand | Notes |
|---|---|---|---|
| SOFA-001 | Nord Cloud Sofa | Nord | synonym target for couch |
| TV-55-OLED | 55 inch OLED Television | ViewMax | synonym target for TV |
| MUG-BLUE-01 | Blue Ceramic Mug | HomeCo | exact match staple |
| DRAFT-999 | Secret Draft Chair | HiddenCo | unpublished |
Step 3: Author the first 15 cases
- Exact title
Blue Ceramic Mugranks MUG-BLUE-01 in top 3. - SKU
MUG-BLUE-01returns that product first. - Query
couchreturns SOFA-001 via synonym. - Query
tv oledreturns TV-55-OLED in top results. - Case variants of
mugare equivalent. - Outer spaces around
mugare equivalent. - Query
zzzznotaproductshows empty state. - XSS query is escaped in results UI.
- Brand filter HomeCo + query mug keeps only HomeCo mugs.
- Price ascending sort is monotonic on visible items.
- Page 2 has no page 1 duplicates under price sort.
- DRAFT-999 never appears for public user.
- Newly published product appears within 5 minutes.
- Unpublished product disappears within 5 minutes.
- Autocomplete keyboard select navigates correctly.
Step 4: Execute and score
Track pass/fail and also a simple relevance score for golden queries:
| Query | Top result OK? | Notes |
|---|---|---|
| Blue Ceramic Mug | Yes/No | |
| MUG-BLUE-01 | Yes/No | |
| couch | Yes/No | synonym |
| tv oled | Yes/No | multi-token |
If synonym fails, that is not "search broken globally." It is a specific configuration defect. Good cases make that diagnosis obvious.
Step 5: Promote survivors into regression
Any failed production search complaint should become a golden query with a permanent case ID and owner. Search suites improve when they absorb real user language, not only tidy QA language.
Search Test Case Template You Can Reuse
Test Case ID:
Title:
Requirement Reference:
Priority:
Type: Functional | Relevance | Facet | Security | Permission | Performance smoke
Preconditions: index state, user role, locale, feature flags
Query:
Filters/Sort:
Test Data / Expected entities:
Steps:
Expected Result:
- must include:
- must exclude:
- ranking note:
- empty state note:
Actual Result:
Status:
Notes: index time, personalization off/on
Using a dedicated "must include / must exclude / ranking note" block prevents vague expected results.
How Search Fits Release Gates
Not every release needs the full relevance lab. Use layered gates:
| Gate | When | Suite slice |
|---|---|---|
| PR smoke | search code changes | exact ID match, empty query rule, one filter |
| Nightly | main branch | golden top 20 queries, facet matrix sample, authz |
| Pre-release | marketing events | merchandising pins, campaign synonyms, mobile UX |
| Post-incident | ranking bug escaped | new golden queries plus related regression |
This keeps test cases for search functionality maintainable instead of turning into an unprioritized pile.
Collaboration Tips With Product and Engineering
Search quality is shared ownership.
- Product defines business-critical queries and synonym intent.
- Engineering explains analyzer behavior and index lag.
- QA turns those into executable cases and evidence.
- Merchandising validates boost and pin expectations during campaigns.
A short weekly 20-minute search triage on zero-result analytics often yields better suite growth than writing cases in isolation. Pull top failed queries from analytics, convert them into cases, and re-check after ranking changes.
Conclusion
Effective test cases for search functionality validate that users can find the right things quickly, safely, and consistently. Cover query handling, relevance, facets, empty states, permissions, and freshness, not just the presence of a results list. Build a golden query set for business-critical terms, assert precise expected results, and keep a fast smoke pack for release gates.
Search is often the difference between a rich catalog and a usable product. When your suite protects both retrieval correctness and ranking usefulness, you protect discovery, conversion, and trust in one place.
FAQ
Questions testers ask
What are the key test cases for search functionality?
Cover valid keyword matches, partial matches, case insensitivity, no-results behavior, empty query handling, filters and sort interaction, result accuracy against source data, special characters, and performance under normal load. Add typo tolerance, synonyms, and ranking checks when the product promises them.
How do you test search relevance?
Build a golden query set with expected top results, then judge whether the best match appears near the top. Compare exact title matches, popular items, and synonym cases. Relevance is not only 'some results returned.' It is whether useful results rank correctly for real user queries.
What should happen when search returns no results?
Users should see a clear empty state, optionally spelling suggestions, popular or nearby categories, and an easy way to edit the query. The page should not look broken, show null errors, or display unrelated products as if they matched unless labeled as recommendations.
How do you test search with filters and sort?
Apply each filter alone, combine filters, change sort after filtering, remove filters, and verify counts. Confirm URL state if shareable, and ensure filter options do not include impossible combinations that yield silent zero results without explanation.
Should search be case sensitive?
For most product and content search experiences, queries should be case insensitive. Test `Shoe`, `shoe`, and `SHOE` for equivalent results unless the domain intentionally requires case sensitivity, such as some code or ID search tools.
What security tests apply to search boxes?
Try XSS payloads in queries and ensure results pages escape output. Check that unauthorized users cannot surface private records through search. Very long queries should not crash the service. SQL-like strings must not bypass authorization or expose schema errors.
RELATED GUIDES
Continue the route
Test Cases for an E-commerce Website
Complete test cases for an e-commerce website: catalog, cart, checkout, payments, orders, returns, and risk-based QA coverage with clear examples.
How to Write Test Cases: Complete Guide with Examples
Learn how to write test cases with practical steps, examples, a QA template, common mistakes, and review tips for reliable software coverage.
Boundary Value Analysis and Equivalence Partitioning Explained
Learn boundary value analysis and equivalence partitioning with examples, robust BVA rules, interview tips, and how to design sharper test cases.
How to Write Test Cases for a Text Field / Input Box
Learn how to write test cases for a text field with validation, boundaries, unicode, paste, accessibility, and security examples you can reuse.