function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
prasanth kumarprasanth kumar 

map with test class not wokring. please help.

sir,  please solve this error.
 
simple test class for map. getting error at line 7 :  Variable is not visible: colors


@istest
public class apex2test {

    testmethod static void apex2test()
    {
        apex2 ap=new apex2();
        system.assertEquals(ap.colors.get('green'),'this is start signal');
    }
}





apex class:----------



public class apex2 {

   public map<string,string> colors;
    
    public apex2()
    {
        colors=new map<string,string>();
        
        colors.put('red','this is stop signal');
        colors.put('green','this is start signal');
        colors.put('yellow','thisis slowdown signal');
    
        system.debug('the data of red is: '+colors.get('red'));
        system.debug('the count of colors is: '+colors.size());
        
    }
        }

 
Best Answer chosen by prasanth kumar
Shrikant BagalShrikant Bagal
Do you really think its not working beacase all is good.

All Answers

Shrikant BagalShrikant Bagal
Do you really think its not working beacase all is good.
This was selected as the best answer
Krishna SambarajuKrishna Sambaraju
Are you sure that the variable "colors" is public as shared in the above code.
prasanth kumarprasanth kumar
actually it show the error for some period.  now its working well..  i dont know why it was shown an error even if every thing is correct.  Thank you Shrikant.