Any tips for testing Box integrations that are used in apex? I’m not sure whether it’s better to
Surround all Box methods/auth/api calls in apex with if(!Test.isRunningTest()) so that those lines of code are skipped?
Create mock HTTP responses to be able to step through the lines of code if a test is running?
eg.
HttpResponse response = Test.isRunningTest() ? new Http().send(request) : toolkit.sendRequest(request);
- Something better?
I can see #2 perhaps being best practice, however we use many different box methods (createFolder(), createFolderForRecordId(), commitChanges(), moveFolder(), getFolderByRecordId(), etc) and this could be very tedious to create custom responses for each one. Thoughts?