I need Opportunity record to be inserted in test class and then use that Id in webservice call out. Tried every different combination but it asks me commit the DML operation before doing webservice call out and test class fails. Is there any standard way of data creation before doing webservice callout test ?
Here is my code:
@isTest
public class className_Test{
public static Opportunity doDML()
{
//Logic to insert required records
}
public static testMethod void TestInterfaceCallout()
{
Opportunity opp = doDML();
//Mock implementation called
Test.setMock(WebServiceMock.class, new TestInterface_MockImpl());
Test.startTest();
WebserviceCls.WebServiceMethod(opp.Id);
Test.stopTest();
}
Is there anything I am missing or is that impossible to do ?
static Opportunity opp = doDML();
?