function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nicholas TurittoNicholas Turitto 

Cannot mock a callout in managed package

I am working with some Apex test code that calls dfsle.TestUtils.setMock(new dfsle.ESignatureAPIMock()), to enable a mock for web service callouts to DocuSign in the Apex code that is being tested.  That DocuSign mock is in a managed package, so I can't call Test.setMock() to enable the mock.  Additional code has been added in the Apex code that is being tested, that requires another web services mock to handle another web service callout.  Salesforce only allows you to mock a single REST service in a test.  I've seen an example in which a mock will simply call the doInvoke() method on the appropriate mock, but the doInvoke() method call isn't availble in the DocuSign mock in the managed package.  Is there a way that I could programatically enable both mocks in this case?
 
AbhishekAbhishek (Salesforce Developers) 
You can try the code suggestions as mentioned below,

https://salesforce.stackexchange.com/questions/172435/unable-to-implement-httpmock-from-managed-package-in-local-test-methods-comple

https://blog.moothien.me/2018/12/mock-http-callouts-in-managed-package.html?m=1

I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.

Thanks.