Another one for the hardcore folks:
I have a Remote Action in a controller extension class. The Remote Action method invokes a static method on a helper class which then performs a web callout. The Remote Action has no knowledge of the HTTP request/response ceremony in method it is calling nor should it.
Not quite sure of the proper way to test the Remote Action w/o setting up a HttpCalloutMock implementation.
// Arrange <br /> ... <br />Test.setMock(HttpCalloutMock.class, new TRKD_MockHttpResponseGenerator());<br /> <br />// Act<br />String jsonReponse = MyController.doSomethingReturnJSONString();<br /> <br />// Assert<br />System.assert(jsonReponse != null);
It seems to me that I should not have to set up a HttpCalloutMock class since my Remote Action method has no knowledge of the MyController.doSomethingReturnJSONString method implementation i.e. code smell.
Do I change MyController.doSomethingReturnJSONString method to check for Test.IsRunningTest() and return an appropriate response?
Any advice would be appreciated.
Yes, the Remote Action is being invoked from a Skuid page.