You need to sign in to do that
Don't have an account?
rmranjith8881.3927046400771116E12
Increase Test Code Coverage for Triggers
Hi All,
I have a 3 Triggers in my Sandbox,
I would like to deploy my Appliction into production,
But The Total Test coverage of organization is 70%,
I want to increase my Test code coverage 75% +.
For those Triggers we have managed Test classes .
The managed coe is unavailable.
How can i increase my code coverage?
can anyone help me out,
Thanks in advance.
I have a 3 Triggers in my Sandbox,
I would like to deploy my Appliction into production,
But The Total Test coverage of organization is 70%,
I want to increase my Test code coverage 75% +.
For those Triggers we have managed Test classes .
The managed coe is unavailable.
How can i increase my code coverage?
can anyone help me out,
Thanks in advance.
My suggestion would be writing a new test class and covering the parts which were not covered by previous test classes.
can you write a sample test class for my trigger?
Here is my triggger:
trigger OppDonationRollup on Opportunity (after insert, after update, after delete) {
Id houseHoldId;
Id donationId;
Double postedAmt=0;
Double pledgeAmt=0;
npo02__Household__c currentHouseHold;
Date rollupSince;
Date rollupEnds; //This line is Added by Ranjith kumar Medishetty on 3/15/2014
//Fetching current record: Donation id
if(Trigger.isDelete){
for(Opportunity opp: Trigger.Old) {
donationId = opp.Id;
houseHoldId = opp.Household__c;
}}else{
for(Opportunity opp: Trigger.New) {
donationId = opp.Id;
houseHoldId = opp.Household__c;
}
}
//Fetching the Rollupsince and Rollupends date from Household
if(houseHoldId !=null){
currentHouseHold =[select Rollup_Since__c,Rollup_ends__c,Pledge_Rollup__c,Posted_Rollup__c
from npo02__Household__c where id=:houseHoldId]; //This line is Modified by Ranjith kumar Medishetty on 3/15/2014
}
if(currentHouseHold !=null){
rollupSince = currentHouseHold.Rollup_Since__c;
rollupEnds= currentHouseHold.Rollup_ends__c; //This line is Added by Ranjith kumar Medishetty on 3/15/2014
}
//Fetching the Posted and Pledge Donations
if(rollupSince == null && rollupEnds == null && currentHouseHold !=null) {//This line is Modified by Ranjith kumar Medishetty Medishetty on 3/15/2014
rollupSince = Date.parse('11/4/2008');
rollupEnds = Date.parse('3/1/2014'); //This line is Added by Ranjith kumar Medishetty on 3/15/2014
currentHouseHold.Rollup_Since__c = rollupSince;
currentHouseHold.Rollup_ends__c= rollupEnds; //This line is Added by Ranjith kumar Medishetty on 3/15/2014
}
if(rollupSince != null && rollupEnds != null && houseHoldId !=null){ //This line is Modified by Ranjith kumar Medishetty on 3/15/2014
for(Opportunity opp: [select Amount, StageName from Opportunity where Household__r.id=:houseHoldId
and ( CloseDate>=:rollupSince and CloseDate<=:rollupEnds )]){ //This line is Modified by Ranjith kumar Medishetty on 3/15/2014
postedAmt= (opp.StageName.equals('Posted'))? postedAmt+ opp.Amount : postedAmt;
pledgeAmt= (opp.StageName.equals('Pledged'))? pledgeAmt+ opp.Amount : pledgeAmt;
}
}
//Updating the Pledge and Posted rollup amounts
if(currentHouseHold !=null){
if(postedAmt !=null)
currentHouseHold.Posted_Rollup__c = postedAmt;
if(pledgeAmt !=null)
currentHouseHold.Pledge_Rollup__c = postedAmt;
update currentHouseHold;
}
}
Thank you in advance.