Test cases for search functionality: the four that matter
Test cases for search functionality, cut down to four: a term with results, a term with none, cleared, and with a filter. What to type, what must come out.
The test cases for search functionality that find bugs are four: a term that has results, a term that has none, the search cleared again, and the search used together with a filter. The long lists of a hundred search cases contain these four somewhere in the middle, between “search with 10,000 characters” and “search in upper case”. Run the four first. On a small app you may never need the rest.
Each one below has what to type, what must come out, and the way it usually breaks.

Test cases for search functionality need known data
Search test cases fail to mean anything when the data is unknown. “Search for a term and check results appear” passes on any list that isn’t empty.
So make three things with names you chose: Sample item, Sample report, Other thing. Two share a word, one doesn’t. Every case below is checked against those three, and you delete them afterwards.
1. A term with results
Type: sample
Must come out: exactly two rows, Sample item and Sample report. Other thing is not on the page.
Both halves count. A search that returns everything also “shows results for sample”. The row that must be absent is what makes this a test. It is the same rule as for any expected result: name what must be there and what must not.
How it breaks: the search matches only from the start of the name, or only whole words, or only the first page of data. Or it is case sensitive and sample finds nothing while Sample finds two. Decide which behaviour you want and write it into the case.
2. A term with none
Type: zzqx, or any string you are sure is nowhere in your data.
Must come out: a sentence that says nothing matched, the term still in the box, and a way back to the full list.
This is the “no results test”, and it has more ways to go wrong than it looks:
- a blank area, with no words at all,
- a spinner that never stops, because the code waits for a first row,
- the full list, because an empty result fell back to “show all”,
- an error page, because something tried to read the first result of nothing.

A blank area is the hard one for testing, because “no rows” is true of it. A check that only counts rows passes. That is a hollow pass: the test has to look for the sentence.
3. Cleared
Do: after either search, empty the box (or press the clear control, if there is one).
Must come out: all three rows, in their usual order.
It sounds too simple to fail. It fails in two ways. Some searches treat the empty string as one more term and answer “nothing matched”. Others keep the last results on screen, because the code only searches when the box has text in it. Either way the person is stuck in a filtered view with an empty box and reloads the page.
Check the address too, if your search writes the term into it. After clearing, reloading the page must not bring the old term back.
4. A filter with the search
Skip this one if your list has no filter, sort or tab beside the search.
Do: pick a filter that leaves some rows out (say, “Reports only”). Then type sample.
Must come out: only rows that pass both, here Sample report. And the filter control still shows “Reports only”.
Then do it in the other order: type first, pick the filter second. The bug to look for is two controls that don’t know about each other. Typing resets the filter without saying so, or choosing a filter empties the box. The person thinks they are looking at reports that match “sample” and they are looking at everything that matches “sample”.
Search test cases we leave for later
From the long lists, these are the ones we would add next, in order, when the four pass:
- A space before or after the term. People paste.
sampleshould find whatsamplefinds. - The term in another case, if you didn’t settle that in case 1.
- Enter instead of the button, if the search has a button.
- Back. Search, open a result, press Back. Are the term and the results still there?
And the ones we don’t write as functional cases at all: every special character one by one, strings of thousands of characters, and injection strings. We’d expect little from the first two on a search box that passes the cases above. The third is a security test and deserves a proper one, not a line in a QA list.
Search functionality testing by kind of user
One more column, if your app has more than one kind of user: who is searching. A search must never return a row the person couldn’t open from the list. Log in as the second user, search for a word you know is only in the first user’s data, and expect case 2’s answer. It is the IDOR check arriving through a different door.
How EveryRole runs search cases
EveryRole treats a search as its own kind of stop: a search field, or a form inside a search region. At that stop it runs two main cases every time, with the same names as above: Term with results and Term with none. Two extra cases are off until you turn them on: Cleared, and Filter with search, which applies where a filter sits beside the search.
For the term with results, the first answer is shown to you and waits for your yes. After that, every run compares with what you approved, so a search that starts returning everything comes back as “Result changed”.
It runs these on the live site, from outside, as the kind of user the journey belongs to, and the other kinds of user are checked at the stop, as at any stop. It doesn’t know what is in your database, so it can’t tell you a row is missing that should have matched. Your three rows of known data are still the best search test there is.


