I have a class that only contains one map.

public with sharing class testController {
    public Map<String, User[]> mapName {get {.....return value;} set;}

I am unable to instantiate the class or call the method because it is not actually a method. How would I start testing something like this? Is there any documentation on testing with no methods to test? I can't find any documentation on something like this.

I have tried to manually create a user list, query a user list, instantiate the testController, and a few other variations.

1 Answer 1


You can still test it, because classes that have no defined constructors still have a default constructor. So, your unit test would look like this:

@isTest static void test() {
    testController c = new testController();
    System.assertNotEquals(null, c.mapName);
  • ah great. I wasn't calling the assertNotEquals correctly. thank you!
    – Olivia
    Commented Jan 4, 2017 at 0:50
  • @Olivia Glad I could help! Sometimes its the little things we miss.
    – sfdcfox
    Commented Jan 4, 2017 at 0:52
  • how do i test a map on a trigger? @sfdcfox Commented Apr 8, 2019 at 9:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .