function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
developer srideveloper sri 

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:    


if (Trigger.isUpdate && Trigger.isAfter)





for(Quote qt: {  

 if (Trigger.isInsert && Trigger.isAfter) {                    

abc__c abc = new abc__c();            

abc.opportunity__c = qt.OpportunityId;            

abc.Quote__c =;     = qt.Name;            


system.debug(LoggingLevel.DEBUG, '@@@@@ abc object created = ' + abc);


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);





Try to use below sample test class for your trigger code.


Test class:

public class TestQuote{
	Private Static testmethod void TestQuote(){
		Opportunity objOpp = new Opportunity();
		objOpp.Name = 'Test Opp';
		objOpp.Amount = 10;
		objOpp.stageName = 'Prospecting';
		objOpp.Type = 'New Customer';
		objOpp.closedate =;
		insert objOpp;

		Quote objq = new Quote();
		objq.Name = 'Test';;
		insert objq;
		objq.Name = 'Test update';
		update objq;



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:-

developer srideveloper sri

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.