You need to sign in to do that
Don't have an account?
mac admin
Test class for the schema class
Hi all,
Can anyone help me in writting the test class for the below class.
Thanks in advance.
Regarding,
mac.
Can anyone help me in writting the test class for the below class.
trigger EdiGra on Form__c (after update) { Schema.DescribeSObjectResult objSchema = Form__c.sObjectType.getDescribe(); Set<String> fields = objSchema.fields.getMap().keySet(); String[] changedFields = new String[]{}; for(Form__c c: trigger.new){ for(string s: fields){ if(c.get(s) != trigger.oldMap.get(c.Id).get(s)){ changedFields.add('GForm :' + c.Name + ' - ' + s + ' - Old Value:' + trigger.oldMap.get(c.Id).get(s) + ' New Value:' + c.get(s)); } } } if(changedFields.size()>0){ messaging.singleEmailMessage mail = new messaging.singleEmailMessage(); mail.setToAddresses(new string[]{UserInfo.getUserEmail()}); mail.setReplyTo(UserInfo.getUserEmail()); mail.setSubject('Postal updated'); string htmlBody = ''; for (String s : changedFields){ htmlBody += '<div> ' + s + ' </div>'; } mail.setHtmlBody(htmlBody); Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail}); } }
Thanks in advance.
Regarding,
mac.
Use the below code, Create one more method for testing the null pointer exception testing.
Please let me know if this help !
Thanks
Shivdeep
As per your scenerio, no need to insert contact and replace case sobject with your sobject i.e., "Form__c".
update any fields of form__c (In my case i updated status field) and then save.
Thanks
Shivdeep