+ Start a Discussion
Jay GatsbyJay Gatsby 

Can anyone suggest how to write test class for method returning Map<String,Object> ?

I have below sample method

@testVisible
    private static Map<String,Object> getSampleMap(List<Object> sampleList){
        Map<String,Object> sampleMap = new Map<String,Object>();
        if(sampleList!= null && sampleList.size()>0 ){
            for(Object obj : sampleList){
                sampleMap.put(obj.field1,obj);
            }
        }
        return sampleMap ;
    }
Best Answer chosen by Jay Gatsby
WEN JIEWEN JIE
Hi Jay,

For this method "getSampleMap", you need to preprae some test data in your test class and then invoke this metod from your test class (pass the corresponding parameter).

Thanks.