You need to sign in to do that
Don't have an account?
rajesh kumar 50
TEST CLASS FOR THE TRIGGER
Can any one help me to write a test class for the below trigger:
trigger opportunityinsertupdate on opportunity(before insert,before update) {
if(checkRecursive.runOnce()) {
Set<Id> accountIds = new Set<Id>();
for(Opportunity currentOpportunity: Trigger.New) {
accountIds.add(currentOpportunity.AccountId);
}
Map<Id, Account> accountMap = new Map<Id, Account>([Select Id, Super_Region__c from Account Where Id in:accountIds]);
boolean flag=True;
if(trigger.isInsert) {
for(opportunity o : trigger.new) {
if(accountMap.get(o.AccountId) != null) {
if(((o.Record_Type_Name__c == 'NC Power')||(o.Record_Type_Name__c == 'NC Oil & Gas')) && (o.FS_Included__c == false) && accountMap.get(o.AccountId).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:trigger.new) {
if(accountMap.get(o1.AccountId) != null) {
if(((o1.Record_Type_Name__c == 'NC Power')||(o1.Record_Type_Name__c == 'NC Oil & Gas')) && (o1.FS_Included__c == false) && accountMap.get(o1.AccountId).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;
}
}
}
}
}
}
i was trying with inserting a record but i want to try it with
@isTest(SeeAllData=true)
can any suggest me to slove this please
thanks in advance..
trigger opportunityinsertupdate on opportunity(before insert,before update) {
if(checkRecursive.runOnce()) {
Set<Id> accountIds = new Set<Id>();
for(Opportunity currentOpportunity: Trigger.New) {
accountIds.add(currentOpportunity.AccountId);
}
Map<Id, Account> accountMap = new Map<Id, Account>([Select Id, Super_Region__c from Account Where Id in:accountIds]);
boolean flag=True;
if(trigger.isInsert) {
for(opportunity o : trigger.new) {
if(accountMap.get(o.AccountId) != null) {
if(((o.Record_Type_Name__c == 'NC Power')||(o.Record_Type_Name__c == 'NC Oil & Gas')) && (o.FS_Included__c == false) && accountMap.get(o.AccountId).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:trigger.new) {
if(accountMap.get(o1.AccountId) != null) {
if(((o1.Record_Type_Name__c == 'NC Power')||(o1.Record_Type_Name__c == 'NC Oil & Gas')) && (o1.FS_Included__c == false) && accountMap.get(o1.AccountId).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;
}
}
}
}
}
}
i was trying with inserting a record but i want to try it with
@isTest(SeeAllData=true)
can any suggest me to slove this please
thanks in advance..
Here's some help:
http://www.sfdc99.com/2013/05/14/how-to-write-a-test-class/
https://developer.salesforce.com/page/How_to_Write_Good_Unit_Tests