You need to sign in to do that
Don't have an account?

Issue with test class not running Standardcontroller getRecord()...
Hello all,
Im having an issue getting my test class to execute the getRecords() method. The error is a dereference null value on the line where that method is used. How do I get it to recognize the value Im trying to pass into the controller from the test class?
@isTest private class TestSalesConnectContactQuickBuild { static testMethod void myUnitTest() { Unmatched_Contact__c contactRecord = new Unmatched_Contact__c(Last_Name__c='TESTDATA',OwnerId=UserInfo.getUserId(),Firm_Internal_ID__c='1'); insert contactRecord; Test.startTest(); ApexPages.Standardcontroller stdCtrl = new ApexPages.Standardcontroller(contactRecord); SalesConnectContactQuickBuildController controller = new SalesConnectContactQuickBuildController(stdCtrl); Test.stopTest(); } }
Here is the controller code...
public class SalesConnectContactQuickBuildController { ApexPages.StandardController setController; public list<Unmatched_Contact__c> unmatchedContactsSelected {get;set;} public SalesConnectContactQuickBuildController (ApexPages.StandardController controller) { setController = controller; unmatchedContactsSelected = new list<Unmatched_Contact__c>(); //****ERROR OCCURS ON LINE BELOW - DEREFERENCE NULL VALUE*** unmatchedContactsSelected.add((Unmatched_Contact__c)setCon.getRecord()); init(); } ... }
Is this really the controller code? The reason I ask is I wouldn't expect it to compile, as you have no poperty named 'setCon' which you try to use in the line which is erroring:
If you have an additional property named 'setCon', that would explain the error as you are assigning the standard controller to a property named 'setController'.
All Answers
Is this really the controller code? The reason I ask is I wouldn't expect it to compile, as you have no poperty named 'setCon' which you try to use in the line which is erroring:
If you have an additional property named 'setCon', that would explain the error as you are assigning the standard controller to a property named 'setController'.
Can't believe I missed that. Thank you for your help!