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개
  1. 2025년 7월 10일 오전 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