You need to sign in to do that
Don't have an account?
Testing Callouts using MultiStaticResourceCalloutMock
Hi,
I am using MultiStaticResourceCalloutMock for testing callouts.
I need to use multiple static resource files, so I have zipped the files into single file and uploaded it to static resources.But the setStaticResource() takes only name of staticresource file.
The syntax of setStaticResource() is setStaticResource(String endpoint, String resourceName).
As mentioned in the syntax we can give only resourceName ,but not path of resource.
So,Is there any way to give the path of static resource file to setStaticResource() or any other alternative ?
Any pointers on this will be highly appreciated.
As it is currently implemented, the StaticResourceCalloutMock and MultiStaticResourceCalloutMock only take the full String API name of a Static Resource. You will need a separate Static Resource separately named for each mock response.
When you are setting the endpoints for your multi mocks, make sure you specify the entire endpoint, including query params:
Utilizing previous parts of your responses to create the endpoint strings is about as dynamic as you're going to get with the parameters for the setStaticResource method (unless you want to create static resources with a alphanumeric on the end for a chain of responses).
This assumes some sort of ResponseWrapper class that you can deserialize your JSON response with and access response variables.
Hope that helps! And...
May The SForce Be With You!
youtube.com/MayTheSForceBWithYou
@SForceBeWithYou