You need to sign in to do that
Don't have an account?
How to get trigger code coverage for this simple trigger?
When i deployed my trigger from sanbox to production , the deployement is failed , i found that at least 1% code coverage should need to have in order to deploy...but this trigger have 0% code coverage? what should i do? hw to increses code coverage for this trigger?
trigger UpdateEventRating on Event (before insert, before update) {
for(Event E : Trigger.new){
if(E.Rating__c=='-Excellent Meeting (committed to business within 3 weeks)'){
E.Rating_Value__c=5;
}
else
if(E.Rating__c=='-Good Meeting (Resulted in client meeting agreed to/set or booked a seminar)'){
E.Rating_Value__c=4;
}
else
if(E.Rating__c=='-Productive Meeting (Client specific illustration requested or next meeting scheduled)'){
E.Rating_Value__c=3;
}
else
if(E.Rating__c=='-Average Meeting (Agreed to continued discussions, no client specific activity)'){
E.Rating_Value__c=2;
}
else
if(E.Rating__c=='-Poor Meeting (No potential for future business, no further activity needed)'){
E.Rating_Value__c=1;
}
}
}
Hi Anvesh
No need of writing any apex classes just write a test class which i have provided that mean that we are inserting dummy values as per the condition and sending to production
that test class is for trigger.
we will write test class for Apex classes and Apex triggers before moving it to production.
If you have any doubt regarding solution just ping me.
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Srinivas
SFDC Certified Developer
All Answers
Hi Anvesh,
This gives you full coverage for your trigger else ping me with bit clear requirement.
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Srinivas
SFDC Certified Developer
I am going to give away the code here, I expect you to use the Idea
@isTest(SeeAllData = false)
private class Event_TestClass
{
static testMethod void UnitTestForException()
{
test.startTest();
Event e = new Eevent(ActivityDate = system.today(), ActivityDateTime = system.now(), DurationInMinutes = 2);
insert e ;
update e ;
test.stopTest();
}
}
I havce provided a structure now you can also include fields to get code coverage more.
I dont have class , My requirement is when Rating__c changed according to this trigger should fired and Rating_value__c value is changed accordingly on event page(Activity sobject)....because Rating__c is a picklist type.if we select a value from picklist ('Excellent Meeting')...then this trigger ll need to fire & Rating_value_c populated as 5...like this.
so can i need to write a class? when executes ,... the code execute from test class or tigger? i am confused i have trigger then what is need for to write class...sorry for silly question i am poor in sfdc...pls help me
Hi Anvesh
No need of writing any apex classes just write a test class which i have provided that mean that we are inserting dummy values as per the condition and sending to production
that test class is for trigger.
we will write test class for Apex classes and Apex triggers before moving it to production.
If you have any doubt regarding solution just ping me.
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Srinivas
SFDC Certified Developer
ok got it...but small doubt how did this test class recognises that this class is for trigger...i mean we didnt mentioned trigger name any where then hw this test class recognises its trigger. and can i deploy this test class along with trigger?
i written your test class but trigger code coverage area still showing 0%
can i deploy this class along with trigger?
yes you can..
Sri549,
I have a trigger that I do not know how to develop a class to pass this from sandbox to production can you assist me with this?
trigger triggerCloneNetValue on OpportunityLineItem (before insert, before Update) {
for(OpportunityLineItem opportunityLI : Trigger.new){
opportunityLI.Net_Value_AOP_Installation_OTC_WF__c=opportunityLI.Net_Value_AOP_Installation_OTC__c;
opportunityLI.Net_Value_AOP_Rental_or_Lease_WF__c=opportunityLI.Net_Value_AOP_Rental_or_Lease__c;
opportunityLI.Net_Value_AOP_MRC_WF__c=opportunityLI.Net_Value_AOP_MRC__c;
system.debug(opportunityLI.Net_Value_AOP_Installation_OTC__c);
}
}
Any help will be greatfull
Thanks,
John