I am new to apex and have some questions.
Below are my conditions.
I have class A_Class in which it calls the external end point in some methods.
To test this class, I have already written HTTP mock class and succesfully tested.
I have a schedular class, which calls A_Class to start to run its main method.
I want to test that schedular class.
But when I directly run the schedular with test class, it hits exception because of [TestMethod do not support Web service callouts].
I successfully tested A_Class with HTTP mock class, now I only want to test my schedular whether it is running at sepcific time correctly.
Do I need to comment out the calling of A_Class from schedular when I run test class? If I comment it out, just afraid it gives me problem when I deploy to Production.
How should I approach that kind of situation?
Thanks ahead. Any hints or ideas will be so useful for me.
---Updated (after test)---
(main call method)
Map<String,Object> result = new Map<String,Object>();
if(Test.isrunningtest())
{
// Set mock callout class
Test.setMock(HttpCalloutMock.class, new Test_Class_Mock_Job_RSS());
}
HTTPResponse res = callOutRssJobFeeds(url);
result = getJobRSS(res);
public HTTPResponse callOutRssJobFeeds(String url)
{
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setEndpoint(url);
Http http = new Http();
HTTPResponse res = http.send(req);
return res;
}
Now I am getting [System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out] after updated like above and run the test class.