Quantcast
Viewing all articles
Browse latest Browse all 2

Answer by Eric for (!Test.isRunningTest())-How do we write test class to cover this?

Any chance you did a search first?

Generated code is saved as an Apex class containing the methods you can invoke for calling the Web service. To deploy or package this Apex class and other accompanying code, 75% of the code must have test coverage, including the methods in the generated class. By default, test methods don’t support Web service callouts and tests that perform Web service callouts are skipped. To prevent tests from being skipped and to increase code coverage, Apex provides the built-in WebServiceMock interface and the Test.setMock method that you can use to receive fake responses in a test method.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_wsdl2apex_testing.htm

You will need to implement the above and remove the test.isRunningTest() as it was the old way of doing things where there was no way to test it...


Viewing all articles
Browse latest Browse all 2

Trending Articles