You need to sign in to do that
Don't have an account?
Abraham kumar
Test class not having enough code coverage
HI All,
Please help me for test class for the below Trigger im getting just 62% coverage
Please help me for test class for the below Trigger im getting just 62% coverage
trigger ContactTrig on Account(after update) { List<Contact> ListContact = new List<Contact>(); Set<ID> acctIds = new set<ID>(); for(Account acct : trigger.new) { if(Trigger.oldMap.get(acct.id).Name != acct.Name){ acctIds.add(acct.Id); } } if(acctIds.size() > 0){ for(Contact con : [SELECT id,Email,FirstName,LastName,phone,Title__c,Account.Name,status__c, AccountId FROM Contact WHERE AccountId IN : acctIds AND RecordTypeid = '034D0000000CVERt']) WebServiceCallout.sendNotification(con.Id,con.Email,con.FirstName,con.LastName,con.phone,con.Title__c,con.Account.Name,con.status__c); } } }My Test class is as below please let me know what im missing
@istest public class ContactTrig2TestClass{ static void Accountcreate(){ Account c =new Account(); c.Name = 'Testcon'; c.Type = 'Agency'; insert c; c.Name = 'Testcontract'; update c; } }
Please try after adding @istest for the method Accountcreate like this:
Please let me know if you face any issues and mark this answer if it helped you.
Thanks
Shyama
All Answers
Please try after adding @istest for the method Accountcreate like this:
Please let me know if you face any issues and mark this answer if it helped you.
Thanks
Shyama
This worked
Just would like to know how by just adding @istest to method is it working? while other test classes work without it ...
Many Thanks
Abraham
You can declare test methods in two ways: or
So, if you are using the testMethod keyword, you dont require the @istest annotation. Hope this answered your query.
Thanks.