1

In our Salesforce instance we have what was the SteelBricks package installed. On multiple managed package test classes such as AccountVOTests, there are failures because the buisness dicated that we have a validation field on Assets to ensure that the serial number is filled out. When we run the test classes we receive the below errors. With this said how can we handle correcting test classes of a managed package without removing the validation?

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Serial Number is mandatory to create and save an Asset. Please enter product serial number: [SerialNumber]

  • Honestly, (and this probably isnt best practice), I just ignore them. I assume the developers made the tests mostly for salesforce & themselves, and as long as Im not having a problem with the actual behavior of the package, I leave them as is. Since you can't change the tests to match your validation, or prevent them from firing triggers, they're going to eventually crash on something that they dont have the data to support. So far I havent had any trouble, but most of my packages are very low impact. – battery.cord Jun 20 '18 at 13:26
  • I think it is the right thing to do. The tests must have passed for the package to be uploaded. That is their purpose. You would expect these sorts of validation errors to occur. – fred Jun 20 '18 at 13:44
  • Yes however you are destroying your code coverage. I dont see how you can just let that go – Brooke Jun 20 '18 at 13:46
  • 1
    Managed Package tests are excluded from the overall code coverage calculation – fred Jun 20 '18 at 13:49
  • You know the code is covered because it is enforced at the point that the code is packaged. – fred Jun 20 '18 at 13:49
3

There is no way to edit the tests inside a Managed Package, and you don't need to worry about them.

The tests are there for the package developers to ensure their code functions, and they must pass before they can make the package available to you to install. They must also have at least 75% code coverage.

You would expect these sorts of validation errors to occur, since the package developers have no way of knowing what sort of validation you will have.

Overall code coverage for your org is calculated ignoring classes in managed packages, for the above reasons.

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.