-1

Has anyone ever used contract testing with Salesforce?

Here's my use case:

Salesforce is the provider, I need to consume its APIs from my service, and depending on what payload I send, I will have different responses.

In practice, if I send:

POST /customers
{
   "name": "customerName"
   "region": "USA"
}

I would get

{
   "name": "customerName"
   "region": "USA"
   "status" "within_boundaries"
}

But if the region were to be Australia, then the "status" would be "outside_boundaries".

The type of responses that are returned by Salesforce are very specific to the type of payload sent, in this case, the region will determine what the value of "status" will be.

With that in mind, there's going to be a bunch of requests, in sequence, that will update the object Customer in Salesforce, so that at the end of the workflow I will have a bigger object and other objects associated with it.

What we thought: Use e2e testing from the service and call the Salesforce APIs in sequence, but due to infrastructure problems that are outside of my jurisdiction, the time that a test takes to run, and the 100s of scenarios to cover, this method is not feasible.

So here comes the contract testing, we thought of using a framework like Pact to write consumer tests in the service and provider tests in Salesforce, but here are the questions:

  1. Is it feasible to write providers' tests so that it keeps track of the state of the updated object with each request?

  2. Since there's no wrapper around Pact for Apex, there's a command line tool, how could it be used to leverage the unit tests present in Salesforce?

I am interested in your opinion and experience.

1
  • 2
    This community requires asking only one question at a time. It appears you are asking two questions. Can you narrow this post down to a single problem? Sep 21 at 17:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.