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

can anyone please tell me how to write test class for this trigger class
trigger updateAssessmentValue on Assessment__c(after insert, after update) {
Map<ID, Building__c> parentBuild = new Map<ID, Building__c>();
List<Id> listIds = new List<Id>();
for (Assessment__c childObj : Trigger.new){
listIds.add(childObj.Building__c);
}
parentBuild = new Map<Id, Building__c>([SELECT id, Recent_Assessment_Date__c ,Recent_Assessment_Value__c ,(SELECT ID, Assessment_Value__c,Assessment_Date__c FROM Assessments__r) FROM Building__c WHERE ID IN :listIds]);
for (Assessment__c assess : Trigger.new){
Building__c myBuild = parentBuild.get(assess.Building__c);
myBuild.Recent_Assessment_Date__c = assess.Assessment_Date__c ;
myBuild.Recent_Assessment_Value__c = assess.Assessment_Value__c;
}
update parentBuild.values();
}

Try using the following to model what your test class will look like. I made assumptions as to what were required fields and what the Assessment lookup field api name would be.