You need to sign in to do that
Don't have an account?
Alice Ju
Need help in increasing test coverage
Hi there,
I'm really new to apex and visual force page, and I'm trying to meet the 75% test coverage bar to deploy my VS page. I'm stuck in how to increase the test class now. Take the trigger below for example, the two lines that I mark as bold is marked as "not covered" in the developers console. And these two lines won't fire off any trigger, so I really don't know how to write a test class for code like this. Can any one be so kind and give me some advise? Thank you!
List<Opportunity> AllClosedOp= [SELECT AccountId, Id,Invoiced_Date__c, Renewal_Due_Date__c, CloseDate
from Opportunity where AccountId in :accountIds and (StageName='Closed Won' OR StageName='Closed Won Waiting for invoice')];
List<Contact> AllContact=[Select Id, AccountId, Contact_Role__c From Contact where AccountId IN :accountIds and Contact_Role__c!=Null];
For(Opportunity opt:AllClosedOp)
{
ClosedWonOps.get(opt.AccountId).add(opt);
}
For(Contact ct:AllContact)
{
AccountContacts.get(ct.AccountId).add(ct);
}
I'm really new to apex and visual force page, and I'm trying to meet the 75% test coverage bar to deploy my VS page. I'm stuck in how to increase the test class now. Take the trigger below for example, the two lines that I mark as bold is marked as "not covered" in the developers console. And these two lines won't fire off any trigger, so I really don't know how to write a test class for code like this. Can any one be so kind and give me some advise? Thank you!
List<Opportunity> AllClosedOp= [SELECT AccountId, Id,Invoiced_Date__c, Renewal_Due_Date__c, CloseDate
from Opportunity where AccountId in :accountIds and (StageName='Closed Won' OR StageName='Closed Won Waiting for invoice')];
List<Contact> AllContact=[Select Id, AccountId, Contact_Role__c From Contact where AccountId IN :accountIds and Contact_Role__c!=Null];
For(Opportunity opt:AllClosedOp)
{
ClosedWonOps.get(opt.AccountId).add(opt);
}
For(Contact ct:AllContact)
{
AccountContacts.get(ct.AccountId).add(ct);
}
In that case the query returns some data and control goes into the loop. This way the two lines will be covered.
You mentioned that these two lines do not fire off any trigger. How is this code executed and what other code calls this code?
Regards,
Satish Kumar