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
Nishant Kumar 274Nishant Kumar 274 

Please help me in writing a test class for a trigger helper class

Please help me in writing a test class for a trigger helper class for below code:-
public class DiscountTriggerHelper {
    
    public static void beforeTrigApplyDiscount(List<Discount__c> discounts){
        
        for(Discount__c disc : discounts){
            If(disc.Discount_Applied__c == false && disc.Amount__c >= 100){
                disc.Amount__c = disc.Amount__c + 10;
                disc.Discount_Applied__c = true;
            }
        }
    }
}
Best Answer chosen by Nishant Kumar 274
CharuDuttCharuDutt
Hii
@isTest
public class TestClass{
@isTest
    public static void unitTest(){
        Discount__c dis = new Discount__c ();
        dis.Discount_Applied__c = false;
        dis.Discount_Applied__c = 200;
        //Fill All Required fields
        insert dis;
    }
}
Please Mark It As Best Asnwer If It Helps
Thank You!

All Answers

CharuDuttCharuDutt
Hii
@isTest
public class TestClass{
@isTest
    public static void unitTest(){
        Discount__c dis = new Discount__c ();
        dis.Discount_Applied__c = false;
        dis.Discount_Applied__c = 200;
        //Fill All Required fields
        insert dis;
    }
}
Please Mark It As Best Asnwer If It Helps
Thank You!
This was selected as the best answer
Nishant Kumar 274Nishant Kumar 274
Thanks Charu
JaneJLocaneJaneJLocane
Thanks for the detailed explanation. At school, my writing was poor. And at the university it became even more difficult. I decided to turn for help to ghostwriter service https://www.academicghostwriter.org/ since the work was quite voluminous and serious. And it took more time compared to school. As you grow older, every minute is precious.