You need to sign in to do that
Don't have an account?
Antoine Leleu
Test a customer controller calling an HttpCallout Class ?
Hi all,
I developed a Http Callout Class. I can cover this code at 100% with a test method using MockHttpResponseGenerator.
Then i developed a custom controller calling this Http Callout Class and i'm trying to develop the test metohd for this controller.
If i run my test, i obtain this error "Methods defined as TestMethod do not support Web service callouts, test skipped".
So, i read in the forum that i had to add a condition on my http call out call like this "if (!System.Test.isRunningTest())" to execute my test.
But in this case, my Call Out class is not covered at 100% cause the lines between the condtion can be executed.
Has someone already encountered this problem ? Is there any solution or workaround for this ?
Thanks,
Antoine
I developed a Http Callout Class. I can cover this code at 100% with a test method using MockHttpResponseGenerator.
Then i developed a custom controller calling this Http Callout Class and i'm trying to develop the test metohd for this controller.
If i run my test, i obtain this error "Methods defined as TestMethod do not support Web service callouts, test skipped".
So, i read in the forum that i had to add a condition on my http call out call like this "if (!System.Test.isRunningTest())" to execute my test.
But in this case, my Call Out class is not covered at 100% cause the lines between the condtion can be executed.
Has someone already encountered this problem ? Is there any solution or workaround for this ?
Thanks,
Antoine
If you have a "MockHttpResponse" class, then you're most of the way there.
In your test, you just have to pass that in to your Test.setMock() call before running Test.startTest().
See the last example here: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_wsdl2apex_testing.htm