+ Start a Discussion
MUSFAR KT 6MUSFAR KT 6 

prefix first name with Dr when new lead is created or updated.

trigger Prefix_Dr on Lead (before insert,before update) {
    for(lead L:trigger.new){
       L.FirstName='Dr.'+L.FirstName;
        }
}
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@istest
public class Prefix_Dr_test {
    testmethod static void test(){
        Lead L=New Lead();
        L.FirstName='Dr.Midul';
        L.LastName='ahmed';
        L.Company='sfdc';
        L.Status='Working-contacted'; 
        insert L;
        
        Lead Le=[select Id,firstname,lastname from lead where company='sfdc'];
       System.assertEquals(Le.FirstName.ContainsIgnoreCase('Dr.'),'Dr.');
           
    }


here test class is showing error
Best Answer chosen by MUSFAR KT 6
Team Codekiat.comTeam Codekiat.com
Hi Musfar, found the issue. 

System.assertEquals(Le.FirstName.ContainsIgnoreCase('Dr.'),'Dr.'); In this line of code, first parameter is boolean, hence you need to make changes as below. 

System.assertEquals(Le.FirstName.ContainsIgnoreCase('Dr.'), true);

test this and let us know the outcome. 

Naveen
Team codengine.in 

All Answers

Team Codekiat.comTeam Codekiat.com
Hi Musfar, 

what is the error you are seeing? add more details if you still facing the issue. 

Naveen
Team Codekiat.comTeam Codekiat.com
Hi Musfar, found the issue. 

System.assertEquals(Le.FirstName.ContainsIgnoreCase('Dr.'),'Dr.'); In this line of code, first parameter is boolean, hence you need to make changes as below. 

System.assertEquals(Le.FirstName.ContainsIgnoreCase('Dr.'), true);

test this and let us know the outcome. 

Naveen
Team codengine.in 
This was selected as the best answer
MUSFAR KT 6MUSFAR KT 6
Thanks for support