+ Start a Discussion

Functional Testing

I would like to do some functional testing of our servlet's integration with Salesforce using JUnit and HTTPUnit. However, I don't want to connect to Salesforce using a company account because I don't want to mess with live data. Does anyone have a suggestion for doing this type of testing?

One thought I had was to somehow load our Salesforce customizations into my sforce account but I don't know of any way to do that. Suggestions are welcomed!

Hi Jason,

The only current option is to duplicate the environment as closely as possible in a Developer Edition account. 

Just in case anyone else is wanting to do something of the same nature...

The solution I came up with was to write another servlet (MockSalesforceServlet) that accepts calls from our production servlet. I created a class called SforceServiceLocatorForTesting which is an exact copy of SforceServiceLocator with the exception of changing the Soap_address instance variable to point to my MockSalesforceServlet. Our production servlet has an initParam that is set to the SforceServiceLocatorForTesting class name and that locator is loaded at init time. When I run my functional tests the production servlet calls out to the MockSalesforceServlet which then responds with canned data according to the request that came in (eg. a LoginRequest gets a LoginResult, an OpportunityRequest gets an OpportunityResult, etc.).

The solution seems to be working out just fine for testing and general development.

I will say, however, that it would be nice if Salesforce would offer some way of duplicating the environment of a production account into a development account. I don't expect to be able to copy data, just structure.

Thanks for the feedback.