You need to sign in to do that
Don't have an account?
Pallav
The deployment of the trigger failed on the production instance using Eclips deployment.
Hi all,
I have created a trigger whose code is running fine on the dev instance but when I tried to deploy in the production instace the deployment failed and gives me a error message as given below, on the third step of deployment using the Eclips deployment wizard. while validating the trigger.
Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required.
Test coverage of selected Apex Class and Trigger is 0%, at least 75% test coverage is required.
here is the code for the trigger:-
trigger trytrigger on OpportunityLineItem (after insert)
{
if(trigger.isAfter)
{
if (trigger.isInsert)
{
for (OpportunityLineItem c :trigger.new)
{
Date strDate;
Integer intDayTotal;
Integer intMonth;
OpportunityLineItemSchedule [] OLI = [Select Id, ScheduleDate from OpportunityLineItemSchedule where OpportunityLineItemId=:c.Id order by ScheduleDate];
OpportunityLineItem opp = new OpportunityLineItem(Id=c.Id);
for(OpportunityLineItemSchedule o:OLI)
{
strDate=o.ScheduleDate;
Integer strMonth=strDate.month();
Integer intDay=strDate.day();
if(strMonth==1 || strMonth==3 || strMonth==5 || strMonth==7 || strMonth== 8 || strMonth==10 || strMonth==12)
{
intDayTotal=31;
intDayTotal=intDayTotal-intDay;
}
else if(strMonth==4 || strMonth==6 || strMonth==9 || strMonth==11)
{
intDayTotal=30;
intDayTotal=intDayTotal-intDay;
}
else if(strMonth==2)
{
intDayTotal=28;
intDayTotal=intDayTotal-intDay;
}
strDate=strDate.addDays(intDayTotal);
opp.Test_Field__c=strDate;
}
update opp;
}
}
}
}
Please let me know what I am doing wrong??
Thanks in anticipation of your reponse.
thanks and regards
pallav
I have created a trigger whose code is running fine on the dev instance but when I tried to deploy in the production instace the deployment failed and gives me a error message as given below, on the third step of deployment using the Eclips deployment wizard. while validating the trigger.
Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required.
Test coverage of selected Apex Class and Trigger is 0%, at least 75% test coverage is required.
here is the code for the trigger:-
trigger trytrigger on OpportunityLineItem (after insert)
{
if(trigger.isAfter)
{
if (trigger.isInsert)
{
for (OpportunityLineItem c :trigger.new)
{
Date strDate;
Integer intDayTotal;
Integer intMonth;
OpportunityLineItemSchedule [] OLI = [Select Id, ScheduleDate from OpportunityLineItemSchedule where OpportunityLineItemId=:c.Id order by ScheduleDate];
OpportunityLineItem opp = new OpportunityLineItem(Id=c.Id);
for(OpportunityLineItemSchedule o:OLI)
{
strDate=o.ScheduleDate;
Integer strMonth=strDate.month();
Integer intDay=strDate.day();
if(strMonth==1 || strMonth==3 || strMonth==5 || strMonth==7 || strMonth== 8 || strMonth==10 || strMonth==12)
{
intDayTotal=31;
intDayTotal=intDayTotal-intDay;
}
else if(strMonth==4 || strMonth==6 || strMonth==9 || strMonth==11)
{
intDayTotal=30;
intDayTotal=intDayTotal-intDay;
}
else if(strMonth==2)
{
intDayTotal=28;
intDayTotal=intDayTotal-intDay;
}
strDate=strDate.addDays(intDayTotal);
opp.Test_Field__c=strDate;
}
update opp;
}
}
}
}
Please let me know what I am doing wrong??
Thanks in anticipation of your reponse.
thanks and regards
pallav
Thanks for your response. The user guide that you are talking about does not provide much instruction on how to do it... I am preety new at it and getting totally confused where to create and how to create...it would be a great favour if you can throw some light at it.
Thanks in anticipation of your response.
regards
pallav
Now run your test to get the coverage %.
here is my code for the apex class:-
public class testCodeCoverage
{
static void me()
{
System.debug('test');
}
static testMethod void myTest()
{
me();
OpportunityLineItem acccobj = new OpportunityLineItem(OpportunityId = '1111111', Description='This is a test descriptiion', Quantity=3, UnitPrice=5000, PricebookEntryId='111111');
insert acccobj;
}
}
To my understanding inserting a OpportunityLineItem should trigger all the lines of the trigger. Please correct me if I am wrong. Thanks in advance in anticiaption of your response. Urgent help required.
Thanks and regards
Pallav
Message Edited by Pallav on 02-05-2008 05:26 AM