You need to sign in to do that
Don't have an account?
rajesh kumar 50
Test class for the trigger?
i was facing problem with the test class for the following trigger.
trigger opportunityinsertupdate on opportunity(before insert,before update) {
boolean flag=True;
if(trigger.isInsert) {
for(opportunity o :[Select Id, Name, Record_Type_Name__c, FS_Included__c, account.Super_Region__c, Check__c,
stagename, amount, CurrencyIsoCode, Target_ShipDate__c
From Opportunity Where Id IN :trigger.new]) {
if(((o.Record_Type_Name__c == 'NC Power')||(o.Record_Type_Name__c == 'NC Oil & Gas')) && (o.FS_Included__c == false) && (o.account.Super_Region__c == 'Asia/India')) {
o.stagename = 'Sales Lead';
o.amount = 1;
o.CurrencyIsoCode = 'USD';
o.Target_ShipDate__c = o.Target_ShipDate__c.addmonths(3);
flag = false;
}
}
}
if(trigger.isUpdate && flag) {
for(opportunity o1 :[Select Id, Name, Record_Type_Name__c, FS_Included__c, account.Super_Region__c, Check__c,
stagename, amount, CurrencyIsoCode, Target_ShipDate__c
From Opportunity Where Id IN :trigger.new]){
if(((o1.Record_Type_Name__c == 'NC Power')||(o1.Record_Type_Name__c == 'NC Oil & Gas')) && (o1.FS_Included__c == false) && o1.account.Super_Region__c == 'Asia/India' && o1.Check__c == false) {
o1.stagename = 'Sales Lead';
o1.amount = 1;
o1.CurrencyIsoCode = 'USD';
o1.Target_ShipDate__c = o1.Target_ShipDate__c.addmonths(3);
o1.Check__c = true;
}
}
}
}
can any one tell how to caver this trigger
trigger opportunityinsertupdate on opportunity(before insert,before update) {
boolean flag=True;
if(trigger.isInsert) {
for(opportunity o :[Select Id, Name, Record_Type_Name__c, FS_Included__c, account.Super_Region__c, Check__c,
stagename, amount, CurrencyIsoCode, Target_ShipDate__c
From Opportunity Where Id IN :trigger.new]) {
if(((o.Record_Type_Name__c == 'NC Power')||(o.Record_Type_Name__c == 'NC Oil & Gas')) && (o.FS_Included__c == false) && (o.account.Super_Region__c == 'Asia/India')) {
o.stagename = 'Sales Lead';
o.amount = 1;
o.CurrencyIsoCode = 'USD';
o.Target_ShipDate__c = o.Target_ShipDate__c.addmonths(3);
flag = false;
}
}
}
if(trigger.isUpdate && flag) {
for(opportunity o1 :[Select Id, Name, Record_Type_Name__c, FS_Included__c, account.Super_Region__c, Check__c,
stagename, amount, CurrencyIsoCode, Target_ShipDate__c
From Opportunity Where Id IN :trigger.new]){
if(((o1.Record_Type_Name__c == 'NC Power')||(o1.Record_Type_Name__c == 'NC Oil & Gas')) && (o1.FS_Included__c == false) && o1.account.Super_Region__c == 'Asia/India' && o1.Check__c == false) {
o1.stagename = 'Sales Lead';
o1.amount = 1;
o1.CurrencyIsoCode = 'USD';
o1.Target_ShipDate__c = o1.Target_ShipDate__c.addmonths(3);
o1.Check__c = true;
}
}
}
}
can any one tell how to caver this trigger
You will not be able to get the 100% code coverage for the trigger due to flag = true.
You have create a class with static variable as below to have the same implemenation and to have 100% code coverage>
Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.