You need to sign in to do that
Don't have an account?
kailash chandra
create test class to insert metadata record
Hello,
I need the 100% code coverage of this code, Where I am retrieving records from custom metadata. So I need to insert metadata through test class.
Please help me.
I need the 100% code coverage of this code, Where I am retrieving records from custom metadata. So I need to insert metadata through test class.
Please help me.
public class GenerateAccess{ public Map<String,String> revokeAccess(String realmId){ Map<String,String> rtrnMap=new Map<String,String>() ; String errorString=''; List<Token__mdt> tokens=new List<Token__mdt>([Select DeveloperName,MasterLabel,Access_Token__c,Sandbox_Client_Id__c,Sandbox_Client_Secret__c,Refresh_Token_Expires_in__c,Realm_Id2__c from Token__mdt where Realm_Id2__c=:realmId Limit 1]); if(tokens.size()>0){ String encodedString = EncodingUtil.base64Encode(Blob.valueOf(to[0].Sandbox_Client_Id__c+':'+tokens[0].Sandbox_Client_Secret__c)); } } }
The examples in the following blogs might help
https://www.forcetalks.com/blog/custom-metadata-test-class-coverage-in-salesforce/
http://www.infallibletechie.com/2018/12/code-coverage-for-custom-metadata-type.html
Also if you want to better understand how custom metadata types behave in Apex tests refer to Testing Custom Metadata Types
Anudeep