I have a controller method that uses a SOSL query to generate a list of options. It works when used in the VF page, but the unit test is failing; logging shows the SOSL query is returning no results.
I found this answer to a similar question which states that testing SOSL "is somewhat messy because of indexing delay". It suggests the use of
Test.setFixedSearchResults(), and links to this documentation on testing and SOSL queries.
The documentation states that any SOSL query "that is added to an Apex test method returns an empty set of search results when the test method executes". The explanation and the sample code only addresses SOSL queries that are actually in a test method, but doesn't address SOSL queries that are contained in methods called by a test method. There is a distinction.
SO my question: Are all SOSL queries contained in non-test methods guaranteed to return no results when invoked by a test method? If yes, is this explicitly documented anywhere? The documentation link above is not clear to me (and I've submitted feedback to that effect).