You need to sign in to do that
Don't have an account?
Aditi Mohanty 5
I want test class for this code with 100 % coverage
public class postalcode { @AuraEnabled public static List<Object> call(String p) { List<object> post=new List<object>(); String s=''; List<Object> office=new List<Object>(); List<String> name=new List<String>(); object o; Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint('https://api.postalpincode.in/pincode/'+p); request.setMethod('GET'); HttpResponse response = http.send(request); if (response.getStatusCode() == 200) { List<Object> lst_JsonParse = (List<Object>)Json.deserializeUntyped(response.getBody()); for(Object obj : lst_JsonParse) { Map<String,Object> mp_StrObj = (Map<string,Object>)obj; office=(List<object>)mp_StrObj.get('PostOffice'); } for(object o2:office){ map<String,object> fin=(Map<String,Object>)o2; String a=(String)fin.get('Name'); name.add(a); System.debug(a); } } return office; } }
https://blogs.infosupport.com/thinking-about-test-coverage/
https://stackoverflow.com/questions/1475520/unit-testing-code-coverage-do-you-have-100-coverage
It might help you
I want help in this.