How can I run a unit test on my controller constructor if it contains the following:
originObjectIdString = ApexPages.currentPage().getParameters().get('Id');
When I run the tests, I get an error that the "Argument cannot be null"
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
In this case, you would have to write your test following a pattern like this
Account testAcct = new Account(Name = 'My Account For Testing'); insert testAcct; PageReference thePage = Page.YourVFPage thePage.getParameters().put('id', testAcct.id); Test.setCurrentPage(thePage); Test.StartTest(); <do your thing here> Test.StopTest();