You need to sign in to do that
Don't have an account?

Please help me test class
Hi All,
Below is my trigger code with test class. Please help me test class for code coverage
Thank you Advance.
Below is my trigger code with test class. Please help me test class for code coverage
trigger PropUpdate on D_D__c (after insert, after update) { set<id> accids = new set<id>(); set<D_D__c> amc_recs = new set<D_D__c>(); List<D_D__c>Amc_Lst_Upd = New List<D_D__c>(); map<Id, Id> mp = new map<Id, Id>(); if((Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate)) && checkRecursive.runOnce()){ try{ for (D_D__c am : Trigger.new){ accids.add(am.Account__c); amc_recs.add(am); //mp.add(am.Id, am.Account__c); } if(accids.size() >= 1){ for(Property__c pr : [SELECT Id,Account__c FROM Property__c where Account__c IN:accids]){ mp.put(pr.Account__c, pr.Id); } if(!mp.isEmpty() && !amc_recs.isEmpty()){ D_D__c amc = new D_D__c(); system.debug('amc_recs.size()====='+amc_recs.size()); for(D_D__c amc_lst : amc_recs){ amc.Id = amc_lst.Id; amc.Property__c = mp.get(amc_lst.Account__c); Amc_Lst_Upd.add(amc); } Update Amc_Lst_Upd; } } } catch (Exception e) { System.debug(e); } } } ----------------------------------------------------------------- @isTest public class PropUpdateTest { public static testmethod void PropUpdateTestmeth(){ test.startTest(); Profile p = [SELECT Id FROM Profile WHERE Name='Standard User']; User u = new User(Alias = 'standt', Email='standarduser@testorg.com', EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', LocaleSidKey='en_US', ProfileId = p.Id, TimeZoneSidKey='America/Los_Angeles', UserName='standarduser@testorg.com'); Account acc = new Account(); acc.user__c = u.id; acc.AccountSource = 'Walk-in'; acc.Name = 'testaccount'; insert acc; D_D__c dd = new D_D__c(); dd.account__c = acc.id; dd.Status__c = 'Active'; dd.Actual_Amount__c = 2000; insert dd; Test.stopTest(); } }
Thank you Advance.


Hi Vijay - Can you highlight the lines of code that are not covered with your test class? Thanks

Hi Anudeep thank you for reply. Below lines are not covering