function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Abi V 4Abi V 4 

Unit test for external objects SOQL in Apex class

I have the apex controller for vf page and external objects Queries in the controller are not coevring the code coverage.
Please suggest me how to increase the code coverage for external objects SOQL in apex class.
It really needful if anybody can help me on this as i need to deploy the code into PROD by EOD.
Manish BhatiManish Bhati
Use the following to create a Mock class and return the results you want from the Mock class:-
if (Test.isRunningTest()) { 
  Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());
You need to cover External Objects unit test like the Webservice callout test using mocking.

Write the code for MockHttpResponseGenerator for fulfilling your needs.
Abi V 4Abi V 4
Could you please provide any artice for example to implemete this as i am not sure with this completely.
Manish BhatiManish Bhati
This is very useful article from Salesforce which I have also used for Webservice callouts test:-
Abi V 4Abi V 4
It is not working as i have tried ,external objects are differnct than weservice callouts