
4 respostas
Use this code @isTest
private class CaseAccountidTest {
@isTest static void testCaseOne() {
Test.startTest();
//create account
Account acc = new Account();
//enter details
acc.Name = 'Test Account';
insert acc;
//create case
Case c = new Case();
//enter details
c.AccountId = acc.Id;
c.Type = 'My Type';
c.Origin = 'My Origin';
c.Status = 'My Status';
insert c;
RestRequest req = new RestRequest();
RestResponse res = new RestResponse();
req.requestURI = '/services/apexrest/CaseAccountid/'+c.accountId; //Request URL
req.requestBody = Blob.valueof(JsonMsg);
RestContext.request = req;
RestContext.response= res;
CaseAccountid.getCaseById();
Test.stopTest();
}
}