You need to sign in to do that
Don't have an account?
bonny mankotia
Not able to cover the else block.Below is the test Class
@isTest
public class TestConTrigg
{
static testmethod void testFun()
{
account acc = new account();
acc.name ='less';
insert acc;
contact con = new contact();
con.lastname = 'ram';
con.password__c = 'sdaf';
con.Accountid = acc.Id;
insert con;
account acc1 = new account();
acc1.name ='less';
insert acc1;
contact con1 = new contact();
con1.Accountid = acc1.Id;
con1.account.name = con1.lastname = ' ';
con1.password__c = 'sdaqwe';
update con1;
}
}
Stuck in Trigger Test Class
Not able to cover the else block.Below is the test Class
@isTest
public class TestConTrigg
{
static testmethod void testFun()
{
account acc = new account();
acc.name ='less';
insert acc;
contact con = new contact();
con.lastname = 'ram';
con.password__c = 'sdaf';
con.Accountid = acc.Id;
insert con;
account acc1 = new account();
acc1.name ='less';
insert acc1;
contact con1 = new contact();
con1.Accountid = acc1.Id;
con1.account.name = con1.lastname = ' ';
con1.password__c = 'sdaqwe';
update con1;
}
}
JeffreyStevens
That's because you need to also delete a Contact record in your test class.
Dan1126
Your trigger will never fire on deletion, since you only have after insert and after update declared in the first line. So the Trigger.isDelete boolean will never be true. So change that and then, as Jeffrey said, delete a contact record in your test class.
JeffreyStevens
Right - good catch