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
Rafael MottaRafael Motta 

Code coverage from Record Types


Hi, how are you?
I'm trying to have code coverage Could you support me in determining the reason why the code is not covered?


first of all, Thanks


@isTest
public class ISSM_WSCancelarPedidos_tst {
    static testmethod void processWebService() {
        // VARIABLES
        Id RT_Emergency_id;
        Id RT_GPOrder_id;
        List<RecordType> RecordType_lst = new List<RecordType>();
RecordTypeId_id =  Schema.SObjectType.ONTAP__Order__c.getRecordTypeInfosByDeveloperName().get('Emergency').getRecordTypeId();
                Orders_lst = [SELECT Id, ONCALL__SAP_Order_Number__c, ISSM_IdEmptyBalance__c, toLabel(ONTAP__OrderStatus__c), ONCALL__Order_Created_Date_Time__c, RecordtypeId FROM ONTAP__Order__c WHERE Id =:RegistroId_id];
            
                if (Orders_lst != null  && !Orders_lst.isEmpty()) {
                    for (ONTAP__Order__c reg : Orders_lst) {
                        // Get date of datetime format
                        DateTime date_dt = reg.ONCALL__Order_Created_Date_Time__c;
                        date_dt = date.newInstance(date_dt.year(), date_dt.month(), date_dt.day());
                        
                        // Validate that the record type of the order will be "Emergency" and the status in progress
                        if ((reg.RecordtypeId == RecordTypeId_id) && (reg.ONTAP__OrderStatus__c == System.label.ISSM_OrderStatusInProgress)) {
             
                            if (date_dt == date.today()) {
                                    result_bln = ISSM_WS_CancelaPedidos_helper.UpdateStatusOrder(Orders_lst,'El pedido de emergencia fue cancelado con éxito.',System.label.ISSM_Canceled);
                                if (result_bln == true) {
                                    ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, System.Label.ISSM_SuccessfulSAPOrder));
                            
                                }


The sentence that I have in the test class is as follows.

Id stExam = Schema.getGlobalDescribe().get('ONTAP__Order__c').getDescribe().getRecordTypeInfosByDeveloperName().get('Emergency').getRecordTypeId();
        RecordType_lst = [SELECT Id, Name FROM RecordType WHERE DeveloperName = 'Emergency' LIMIT 1];
        for (RecordType rt : RecordType_lst) { RT_Emergency_id = rt.Id; 
                                              ONTAP__Order__c orderEmergency = new ONTAP__Order__c();
pankul guptapankul gupta
Can you please paste your main Class body for which you are trying to test.