You need to sign in to do that
Don't have an account?

Test Class for External object Data
Hi,
This is regarding the code coverage for the class in which we have used the external object. in our class we are fetching the data from the External object.We have written a test class in such away that, we skipped (using Test.isRunningtest() ) the query which is fetching the data from the external object. But unfortunately we are getting code coverage only 50%. at least we should improve the code coverge to 80% for that class.
So please suggest us how to proceed further.
Kind Regards,
Siva.
This is regarding the code coverage for the class in which we have used the external object. in our class we are fetching the data from the External object.We have written a test class in such away that, we skipped (using Test.isRunningtest() ) the query which is fetching the data from the external object. But unfortunately we are getting code coverage only 50%. at least we should improve the code coverge to 80% for that class.
So please suggest us how to proceed further.
Kind Regards,
Siva.
You might already have the following information but these below links give some information about testing external callouts by mocking responses.
https://developer.salesforce.com/blogs/developer-relations/2013/03/testing-apex-callouts-using-httpcalloutmock.html
http://grahambarnard.com/development/2016/02/08/mocking-external-objects/
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_wsdl2apex_testing.htm
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http_testing.htm
I would suggest you to implement a kind of bypass for the external object, once you can pass
throught the test class the data such:
List<externalobject__x>partsList = new List<externalobject__x>();
partsList = (!mockData.isEmpty()) ? mockData : [select id, value__c from externalobject__x limit 10 ];