You need to sign in to do that
Don't have an account?
Hitesh Khatri 3
What's the code for "Unit Test for simple Appex Trigger" Challange?
I have written the Code for Test Class"TestRestrictContactByName'.
@isTest
private class TestRestrictContactByName {
@isTest static void testRestrictContacts(){
Contact con1 = new Contact(FirstName='Htesh', LastName='khatri');
Test.startTest();
Database.SaveResult Result = Database.insert(con1,false);
Test.stopTest();
System.assert(!result.isSuccess());
System.assert(result.getErrors().size()>0);
System.assertEquals('The Last Name "'+con1.LastName+'" is not allowed for DML',result.getErrors()[0].getMessage());
}
After Running this test i am getting an error 'Challenge not yet complete... here's what's wrong:
The 'RestrictContactByName' class did not achieve 100% code coverage via your test methods' .
Please help me in solving this.
@isTest
private class TestRestrictContactByName {
@isTest static void testRestrictContacts(){
Contact con1 = new Contact(FirstName='Htesh', LastName='khatri');
Test.startTest();
Database.SaveResult Result = Database.insert(con1,false);
Test.stopTest();
System.assert(!result.isSuccess());
System.assert(result.getErrors().size()>0);
System.assertEquals('The Last Name "'+con1.LastName+'" is not allowed for DML',result.getErrors()[0].getMessage());
}
After Running this test i am getting an error 'Challenge not yet complete... here's what's wrong:
The 'RestrictContactByName' class did not achieve 100% code coverage via your test methods' .
Please help me in solving this.
Please find the below test class,
Thanks,
Vinoth
All Answers
Please find the below test class,
Thanks,
Vinoth
Thanks
Amit Chaudhary