Insert Record Type Id or Name in Apex Test Class


 

@isTest()

public class TestcaseUtils {

    private static testmethod  void CreateCaserecord(){

    //Get Case RecordType Id 

Id caseRecordTypeId =      Schema.SObjectType.Case.getRecordTypeInfosByName().get('DeveloperNameOfRecordType').getRecordTypeId();

        //Create Case

        Case CsRec = new Case();

        CsRec.Name ='Test Case Katta';

        CsRec.Status = 'Open';

        CsRec.Type = 'Complaint';

        CsRec.RecordTypeId = caseRecordTypeId;

        Insert CsRec;

    }

}


Post a Comment

0 Comments