Skip to main content
Hello everyone,

Can somebody give me a hand... I just createD this test code, but it is not giving me any code coverage, and no errors neither...

TRIGGER

trigger SelectRecordType on Case (before insert) { 

    for (case cs :Trigger.new){

        if(cs.Type == 'Billing Adjustment'){

            cs.RecordTypeId='012180000004KrD'; 

            }

        else if(cs.Type == 'RMA'){

                cs.RecordTypeId='01240000000IbO4';

            }

    }  

}

TEST

@isTest(seeAllData=True)

public class SelectRecordType_Test {

    static TestMethod void SelectRecordType(){

        case c = new case();

        string tp = c.Type;

        if(tp == 'Billing Adjustment'){

            c.RecordTypeId='012180000004KrD'; 

        } else if(tp == 'RMA'){

            c.RecordTypeId='01240000000IbO4';

        }

    }

}
5 respuestas
  1. 3 jun 2015, 17:38
    Hi Javier ,

    Try with below code it will help ! 

    @isTest

    public class SelectRecordType_Test {

    private static TestMethod void unitTest(){

    case cs = new case();

    cs.Type='Billing Adjustment';

    cs.Status='New';

    cs.Origin='Web';

    Insert cs;

    cs=[SELECT id,Type FROM Case WHERE id=:cs.Id];

    System.assertEquals(cs.Type,'Billing Adjustment');

    }

    private static TestMethod void unitTest1(){

    case cs = new case();

    cs.Type='RMA';

    cs.Status='New';

    cs.Origin='Web';

    Insert cs;

    cs=[SELECT id,Type FROM Case WHERE id=:cs.Id];

    System.assertEquals(cs.Type,'RMA');

    }

    }

    Thanks 

    Manoj
0/9000