Wow, this is exactly what I needed. I need multiple methods to test different status codes and the guide I was following hard codes the status values in the Mock class. I needed this, thanks so much!
Hi, very informative video! I have a doubt though. I have a class which makes an api call. I have the secret key and service url stored in custom metadata. My class retrieves this as a map from the metadata. How do I do the testing for such a class?
Simply just create the desired output or copy the value from the response of that Api. In test ass it will auto pull the metadata info. You just need to call the associated Apex method with necessary params that you might have created and u are good to go. Hope this helps.
Yes in test setup u can put all of them like say 3 account records with different record types etc as per requirement in the corresponding methods u can query them .
Certainly not a waste of time. Thank you very much. Much appreciated.
This is a very nice explanation of how test class donot allow to call actual endpoint. Many Many thanks.
Thanks
Wow, this is exactly what I needed. I need multiple methods to test different status codes and the guide I was following hard codes the status values in the Mock class. I needed this, thanks so much!
Welcome and thanks for supporting
very good example..
Good One
Hi, very informative video! I have a doubt though. I have a class which makes an api call. I have the secret key and service url stored in custom metadata. My class retrieves this as a map from the metadata. How do I do the testing for such a class?
Simply just create the desired output or copy the value from the response of that Api. In test ass it will auto pull the metadata info. You just need to call the associated Apex method with necessary params that you might have created and u are good to go.
Hope this helps.
What if we have to test multiple methods ? Can we put mock code in @testSetup annotation to made these available for all methods in test class?
Yes in test setup u can put all of them like say 3 account records with different record types etc as per requirement in the corresponding methods u can query them .