You need to sign in to do that
Don't have an account?
Need help in Test class
Can somebody help me out in creating Test Class for the below class:
Main aim of my class is to create a "abc object" record on the creation of Quote record.
Relation between abc__c and Quote is lookup relationship:
trigger AA on Quote( after insert) {
List<abc__c> abcs = new List <abc__c>();
List<Id> qtIdList = new List<id>();
for(quote qt: Trigger.new)
{
if (Trigger.isUpdate && Trigger.isAfter)
{
qtIdList.add(qt.id);
}
}
for(Quote qt: Trigger.new) {
if (Trigger.isInsert && Trigger.isAfter) {
abc__c abc = new abc__c();
abc.opportunity__c = qt.OpportunityId;
abc.Quote__c = qt.id;
abc.name = qt.Name;
abcs.add(abc);
system.debug(LoggingLevel.DEBUG, '@@@@@ abc object created = ' + abc);
try{
insert abcs;
} catch (Dmlexception dmlE )
{
system.debug(LoggingLevel.ERROR , 'DML exception while inserting opportunity related inserts =' + dmlE.getMessage());
}
system.debug(LoggingLevel.INFO, '@@@@@ Custom abc inserted = ' + abcs);
}
Hi,
Try to use below sample test class for your trigger code.
Test class:
Important :
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,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/
Thanks for reply!!!
I understood your code.
As I am very new for salesforce, can you please provide me exact test class for my class. I will be very thankfull to you.
Thanks