I am writting a test method for a certain code.This code is fetching Record Type detail from an Object Service_Form__c
.
Class:
String recordTypeName;
Schema.DescribeSObjectResult srfDescribe = Service_Form__c.SObjectType.getDescribe();
for (Schema.RecordTypeInfo recordType : srfDescribe.getRecordTypeInfos()) {
if (recordType.isDefaultRecordTypeMapping()) {
recordTypeName = recordType.Name;
}
}
With in the test class with seeAllData= true
, without any effort, I am able to fetch all recordType deatil from the Object. However, if I am considering seeAlldata = false
, then srfDescribe
is coming null.
Is there any other way, so that we can access a Object's recordtype in the testMethods without inserting an Object record and assigning recordtypes to that record ?