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
Abdul Mujeeb ShaikAbdul Mujeeb Shaik 

In Test class System.NullPointerException

Hi All 
i am getting this error in test class:
Error Msg:
System.NullPointerException: Attempt to de-reference a null object

In My Controller i used this:
 
Map <String, Schema.SObjectField> fieldMap = schemaMap.get(selectedObject).getDescribe().fields.getMap();
        
            Schema.DescribeSObjectResult R = schemaMap.get(selectedObject).getDescribe();
selectedObject is a picklist, there will be always a value 'Sobject'. Please help me out in this. 

Awaitng for ur Response.
Thanks & Regards
Shashikant SharmaShashikant Sharma
Could you please share your full code.

Meanwhile try this :
 
if( schemaMap.get(selectedObject) != null ) {
Schema.DescribeSObjectResult R = schemaMap.get(selectedObject).getDescribe();
}

 
Abdul Mujeeb ShaikAbdul Mujeeb Shaik
this issue was solved, i assigned values in the testclass for that 'selectedObject...code coverage=100% thank you for replying...shashikanth sharnma