+ Start a Discussion
Kanagaraj Arjunan 11Kanagaraj Arjunan 11 

Need Code coverage for Json class

Hi All 

I am trying to write test class for the below class but i couldn't achive this. Anyone have idea about it please explain me .

public class JSON2Apex {

    public class Address_components {
        public String long_name;
        public String short_name;
        public List<String> types;

    public class Northeast {
        public Double lat;
        public Double lng;

    public List<Results> results;
    public String status;

    public class Bounds {
        public Northeast northeast;
        public Northeast southwest;

    public class Geometry {
        public Bounds bounds;
        public Northeast location;
        public String location_type;
        public Bounds viewport;

    public class Results {
        public List<Address_components> address_components;
        public String formatted_address;
        public Geometry geometry;
        public Boolean partial_match;
        public String place_id;
        public List<String> types;
Best Answer chosen by Kanagaraj Arjunan 11
I don't think declarations can be covered, as they are not executable lines. And I also think Salesforce doesn't count them when calculating code coverage. 

If you do want to cover something, try adding blank constructors to your classes and call them using test methods. 

ps: If your question/problem is resolved/answered, please mark your post as 'Solved' so that community can benefit by resolved posts.