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
Ben AebischerBen Aebischer 

Test Class for Quote Trigger

Hi everyone, 

I'm pretty new to Apex and I'm desperately looking for a test class for the following trigger:

Trigger QuoteTriggers on Quote (after insert, after update) { 
Public static boolean IsRun = False; 
for (Quote Q :[SELECT Id,Status, Opportunity.Account.Id, Opportunity.Approval_Status__c FROM Quote WHERE id IN :trigger.New]) { 
If(Trigger.IsInsert){ 
ID QID = Q.ID; 
If(Q.Opportunity.Approval_Status__c == 'Approved' && IsRun == False) { 
Quote ThisQuote = new Quote ( 
Id = QID, 
Status = 'Approved' 
); 
update ThisQuote; 
IsRun = True; 


If (Trigger.IsUpdate && IsRun == False && Q.Opportunity.Approval_Status__c == 'Approved') { 
if (!QuoteStatusUtil.hasQuoteUpdated()) { 
Q.Status = 'Approved'; 
QuoteStatusUtil.setQuoteUpdated(); 
update Q; 

Could anybody help me please?
Thanks : )
 
DeveloperDeveloper
Hello Ben Aebischer,

please find out below link 

https://appexchange.salesforce.com/listingDetail?listingId=a0N3A00000EFozgUAD

instal this test class genarator and try, you will get 100 % code covarage.

Thanks & Regards 
Gopal M.