Test cases for a search box
Updated 2026-11-12 · 4 min read
Search looks easy until you list what it must handle. These 32 cases cover matching rules, input edge cases, suggestions, results, performance and security, with a CSV download.
Assumes a site search for products or articles with a search box, a button, optional suggestions as you type, and a results page with sorting and pagination.
How to answer in an interview
Start by asking what is searched (titles only, descriptions, categories?) and what the matching rules are (exact, partial, typo-tolerant, synonyms?). Then cover input, matching, suggestions, results page, performance and security.
Input
| ID | Category | Test case | Expected result |
|---|---|---|---|
| S01 | Functional | Search a word that exists in several items | Relevant results, best matches first |
| S02 | Functional | Press Enter, and click the search button | Both run the search |
| S03 | Negative | Empty search | Stays on page with a prompt, or shows all items, as specified |
| S04 | Negative | Only spaces | Treated as empty |
| S05 | Functional | Leading and trailing spaces around a word | Trimmed |
| S06 | Functional | Upper, lower and mixed case | Same results |
| S07 | Boundary | One character; the maximum length; one over the maximum | Handled with clear behaviour; no server error |
| S08 | Functional | Very long text pasted | Truncated or rejected politely |
| S09 | Functional | Numbers, hyphens and units (iphone 15, usb-c, 500ml) | Match as expected |
| S10 | Functional | Non-English text and emoji | Works or is rejected cleanly; no garbled text |
Matching
| ID | Category | Test case | Expected result |
|---|---|---|---|
| S11 | Functional | Partial word (mobi for mobile) | Matches if partial matching is specified |
| S12 | Functional | Plural and singular (shoe, shoes) | Same or equivalent results |
| S13 | Functional | A common misspelling (samsng) | "Did you mean" or typo tolerance, if specified |
| S14 | Functional | Multiple words in a different order | Matches if specified (all words, any word) |
| S15 | Functional | Quotes around a phrase, or -word to exclude | Works if advanced syntax is supported |
| S16 | Negative | Search for something that does not exist | A helpful "no results" page with suggestions, not a blank page or error |
Suggestions
| ID | Category | Test case | Expected result |
|---|---|---|---|
| S17 | Functional | Type slowly: suggestions appear after the minimum characters | Relevant, limited in number |
| S18 | Functional | Choose a suggestion with mouse and with arrow keys plus Enter | Search runs for that suggestion |
| S19 | Functional | Type fast, then change text | Suggestions match the latest text, not an old response |
| S20 | Functional | Suggestions do not include hidden or out-of-stock items, if specified | As specified |
Results
| ID | Category | Test case | Expected result |
|---|---|---|---|
| S21 | Functional | Result count matches the number of items across all pages | Equal |
| S22 | Functional | Pagination: next, previous, last page, and a page beyond the last | Correct; no duplicates between pages |
| S23 | Functional | Sort and filter results, then change the query | Behaviour as specified (filters kept or reset) |
| S24 | Functional | Open a result, press Back | Returns to the same results at the same position |
| S25 | Functional | The search term is shown in the results heading and in the URL | Yes; the URL can be shared |
Performance and security
| ID | Category | Test case | Expected result |
|---|---|---|---|
| S26 | Performance | Results appear within the agreed time on a normal connection and on slow 3G | Within limit; a loading state shows |
| S27 | Performance | Many searches in quick succession | No crash; older requests do not overwrite newer ones |
| S28 | Security | <script>alert(1)</script> as the query | Not executed; shown as text, encoded |
| S29 | Security | ' OR 1=1 -- and similar | No error page or data leak |
| S30 | Security | Special characters (% _ \ " & #) | Handled as text |
| S31 | UI | Phone-size screen; the keyboard Search key | Works; layout intact |
| S32 | Compatibility | Repeat S01 on Chrome, Firefox, Safari and Edge | Same behaviour |
Downloads
Want a project you can show in interviews?
The portfolio project kit walks you through testing a deliberately buggy app with Selenium or Playwright and API tests, then explaining it. The app itself is free.
