Thursday, November 3, 2016

Salesforce Test Coverage

As those of you who code Apex know, Salesforce requires at least 75% code coverage to move your logic to production. The documentation on how to achieve that is remarkably lacking. I just spent nearly two days trying to figure out how to test a custom controller because of a Map which, apparently, would not load.

Like many things in this Internet age, I spent hours reading through blogs, posts and other on-line documentation. Finally, in an obscure post, only tangentially associated with the issue, I found what appears to be the answer. My thought is that this is the first thing that you should do.

@isTest(SeeAllData=true) 

The "SeeAllDate=true" did the job. I'm not sure why. To my way of thinking, the information in the Map should have worked just as it did when testing the controller manually, but it didn't. I know this is going to be the first thing I do on all my test classes in the future.

No comments:

Post a Comment