function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
chaithaly gowdachaithaly gowda 

how to compare record type id in test class

Hi

I have to compare the record type id/name using system.assertequals();
Task task = new Task();
            task.Subject = 'Test Send New Task Email Notification';
            task.Status = 'Not Started';
            task.ActivityDate = Date.Today();
            task.Priority = 'Normal';
             task.RecordTypeId = Schema.SObjectType.Task.getRecordTypeInfosByName().get('Operations - Task').getRecordTypeId();
            
            insert(task);
        }
        
      system.assertEquals(Schema.SObjectType.Task.getRecordTypeInfosByName().get('Operations - Task').getRecordTypeId(),task.recordtypeid);
             Test.stopTest();

I am getting below error
Comparison arguments must be compatible types: Id, Schema.SObjectField
AnudeepAnudeep (Salesforce Developers) 
A similar issue is discussed in this post. I recommend taking a look

Let me know if it helps