2

Our solution was to introduce a "settings repository" class. This didn't try to be "all things to all men" and instead exposed custom settings relevant to the app. I'm not even sure it makes sense to try to do that anyway as an app will have certain expectations for the various custom settings types it uses. The class's job is to in-...


2

You can use a class to handle the access to the custom settings and have it implement a custom logic using Test.isRunningTest(). The idea would be that when not running a test, it would return the correct type of the custom setting the caller wants to access. When running a test though, it could search for the value in a private, test visible, map of values. ...


2

Your getAccount() method is static, meaning you don't use an instance of the object to call it, just the class name + method name like MyController.getAccount(). size() is not a method on SObject, but it is a method on collection types (list, set, and map). Instead of asserting size, since you're only returning 1 record, you could assert that acc is not null....


2

Static methods are called through the class name, not through an "instance" of the class. You're also missing the String parameter. In addition, you need to set up test data, because of database isolation in unit tests. Finally, your assertion is incorrect, as the return value was not a list. Account testAccount = new Account(Name='Test'); insert ...


1

The problem may be poorly written tests. For example, some tests may be failing on validation rules, but the errors were swallowed by an indiscriminate try-catch block. You'll want to do a Run All Tests and check the results. If you have Salesforce DX, it's as simple as: sfdx force:apex:test:run -r human -c -w 100 -l RunLocalTests This will (eventually) ...


Only top voted, non community-wiki answers of a minimum length are eligible