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
V AnandV Anand 

Test case assertion failed but test coverage is 100%

Hi..... 

I have written a trigger on lead for awaiding duplication of leads . I have a problem with test case, my test class is

@isTest
private class TestDuplead{
 static testMethod void tm1(){
   lead l=new lead();
   l.lastname='sss';
   l.company='yyy';
   l.email='ve123@gmail.com';
   insert l;
   
   lead l1=new lead();
   l1.lastname='sss1';
   l1.company='yyy1';
   l1.email='ve123@gmail.com';
   try
      {
        insert l1;
      }catch(System.DMLException e){
      system.assert(e.getmessage().contains('lead with this email address already exists')); //line 18
       } 

 I am getting  

 

 

System.AssertException: Assertion FailedClass..TestDuplead.tm1: line 18, column 1

 

If Assertion failed .....is there any problem? 

ManjunathManjunath

Hi,

 

System.assert() functions helps you in validating the output with the expected one.

It is indicating that is not what its expecting. Once you run the test it will show you expected and actual value in report.

That should help you in identifying the mistake.

 

Regards,

Manjunath