I recently ran into an issue where we installed some Service Cloud pieces in our predominantly Sales Cloud org (including the Public Knowledge Base). This installed a few custom APEX classes and tests.

Originally, I did not have a Service Cloud license. Unfortunately, some of the PKB tests require that I have that license -- and likely some additional permissions beyond that -- in order to have access to some of the objects (e.g. Draft Articles) used in the tests and the class itself.

Insufficient access rights: you cannot access draft articles.

Fortunately, there was an open license in this org, but it got me wondering if anyone has run into something similar (inability to deploy new code because they cannot get test cases to run successfully based on permissions)? In this case, I wouldn't be able comment out the tests temporarily because the PKB has a lot of code compared to the amount of other code in the system, and therefore would fall under the 75% code coverage limit. I'm curious if there is any other options outside of stealing the license from a user temporarily in order to deploy any code in the future.


You should use a 'runAs' in the test with a test user and profile that will allow access to the record:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.