You need to sign in to do that
Don't have an account?
Durgamba Rayudu
how to add this test class so that code coverage will improve
for this account wrapper method, added test setup method and test method to cover high priority method. but getting code coverage only 66%
need to add test method for this.
public Boolean isHighPriority(){
if(getRoundedAvgPriceOfOpps() > 100000.00){
return true;
}
return false;
}
I added like this
@isTest static void isHighPriority(){
List<AccountWrapper> accounts = new List<AccountWrapper>();
for(Account a : [SELECT ID, Name FROM ACCOUNT]){
accounts.add(new AccountWrapper(a));}
// sanity check asserting that we have opportunities before executing our tested method.
List<Opportunity> sanityCheckListOfoppsHigh = [SELECT ID FROM Opportunity];
System.assert(sanityCheckListOfoppsHigh.size() > 0, 'You need an opportunity to continue');
Test.startTest();
for(AccountWrapper a : accounts){
System.assertEquals(a.getRoundedAvgPriceOfopps(), 100000.00, 'Expected to get 100000.00');
}
Test.stopTest();
}
need to add test method for this.
public Boolean isHighPriority(){
if(getRoundedAvgPriceOfOpps() > 100000.00){
return true;
}
return false;
}
I added like this
@isTest static void isHighPriority(){
List<AccountWrapper> accounts = new List<AccountWrapper>();
for(Account a : [SELECT ID, Name FROM ACCOUNT]){
accounts.add(new AccountWrapper(a));}
// sanity check asserting that we have opportunities before executing our tested method.
List<Opportunity> sanityCheckListOfoppsHigh = [SELECT ID FROM Opportunity];
System.assert(sanityCheckListOfoppsHigh.size() > 0, 'You need an opportunity to continue');
Test.startTest();
for(AccountWrapper a : accounts){
System.assertEquals(a.getRoundedAvgPriceOfopps(), 100000.00, 'Expected to get 100000.00');
}
Test.stopTest();
}