Skip to main content
edited body
Source Link
sfdcfox
  • 501.8k
  • 21
  • 473
  • 828

The latest call to Test.setFixedSearchResults overwrites whatever happened before. The comment is only meant to state that you can simulate multiple SOSL searches in a single unit test. Of course, this won't help you in some situations, like when you perform multiple SOSL in the same method or trigger. Unfortunately, if that's the case, you might need to perform some mocking or dependency injection, or deal with not having 100% coverage. If there are searches on multiple objects, set all object Ids in the method at once, and the system will sort ourout the ID values (and the records) into the correct SOSL lists.

The latest call to Test.setFixedSearchResults overwrites whatever happened before. The comment is only meant to state that you can simulate multiple SOSL searches in a single unit test. Of course, this won't help you in some situations, like when you perform multiple SOSL in the same method or trigger. Unfortunately, if that's the case, you might need to perform some mocking or dependency injection, or deal with not having 100% coverage. If there are searches on multiple objects, set all object Ids in the method at once, and the system will sort our the ID values (and the records) into the correct SOSL lists.

The latest call to Test.setFixedSearchResults overwrites whatever happened before. The comment is only meant to state that you can simulate multiple SOSL searches in a single unit test. Of course, this won't help you in some situations, like when you perform multiple SOSL in the same method or trigger. Unfortunately, if that's the case, you might need to perform some mocking or dependency injection, or deal with not having 100% coverage. If there are searches on multiple objects, set all object Ids in the method at once, and the system will sort out the ID values (and the records) into the correct SOSL lists.

Source Link
sfdcfox
  • 501.8k
  • 21
  • 473
  • 828

The latest call to Test.setFixedSearchResults overwrites whatever happened before. The comment is only meant to state that you can simulate multiple SOSL searches in a single unit test. Of course, this won't help you in some situations, like when you perform multiple SOSL in the same method or trigger. Unfortunately, if that's the case, you might need to perform some mocking or dependency injection, or deal with not having 100% coverage. If there are searches on multiple objects, set all object Ids in the method at once, and the system will sort our the ID values (and the records) into the correct SOSL lists.