
1 resposta

Hi Siva,I've gone through your apex class, and you must note some important points before writing testClass:-->Important-->{1.You should always write your code of trigger in apexHandlerClass so it would be protable for you to test the trigger and apexClass. Example--> trigger Conference on User__c (after insert,after Update) { if(Trigger.IsAfter) { if(Trigger.IsInsert || Trigger.IsUpdate) { yourApexClass.yourApexMethod(Trigger.New); } } }//trigger //apex class public class yourApexClass { public static void yourApexMethod(List<User__c> allUser) { } } }Below is link of the best practice for writing testclass:https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_best_practices.htmYou should follow below steps to write testclass of your code:1.Create a testDataFactory Class(i.e. apexclass only)-> where it will have all the created data.2.Create Conference record in testdatafactory in bulk 3.Then Create the User record as per your condition defined in query.4.Then Create testclass for your class: example--> @isTest public class yourTestClass { @isTest static void checkTestClass() { //call the testdatafactory method where data is creating Test.startTest(); //your System.assertEquals(expectedResult,yourResult); Test.stopTest(); } } Note:--> You can query yourResult from the data you created and the expectedResult you should return from you apex class I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.Thanks and Regards,Deepali Kulshresthawww.kdeepali.com