Skip to main content

Hi there,

I've made an Apex batch for checking CSAT survey responses. The solution is implemented in Salesforce Surveys. However, when I create the test class, I can't add any record to Survey, SurveyInvitation, SurveyResponse, SurveyQuestionResponse. How could I test the apex code if I can't add record on any of these objects? (SeeAllData=true) is awful and not even feasible, since in production somebody will need to add surveys and answers to them, to deploy the Batch.

Any suggestion would be great! Thanks in advance!

3 respuestas
  1. 10 jul 2025, 10:17

    I mean I can't create test data in a test class for those objects. The only solution is a hard workaround (a best practice as researched) called "repo mocking". That implies to change original class and test class to test a mock instead of original objects. I think I answered the question at this point.

0/9000