I have several AppExchange apps installed that are failing tests. What is the recommended approach to resolving this? Are tests run when a new package is installed? Is there a way to determine what is actually failing besides the name of the method and something like "expected true, actually false"? The test results rarely show enough information to be useful.

What I'm doing atm, is checking for updates for the packages, and then writing the company with the failing test results.

Any feedback would be appreciated.

  • 6
    Do you actually need the managed package test cases to pass? They shouldn't stop you from doing anything else in your Org where they are installed. Tests that originate from installed managed packages are not automatically run in production deployments. Src Dec 1, 2013 at 20:33
  • 1
    Is that true? All of my tests are passing at or above 95% (tests I've written) but my managed packages tests are failing...not sure why else my code coverage would be less than enough to deploy. Also, when I deploy it fails with the managed packages that failed listed as the reason.
    – fourq
    Dec 1, 2013 at 20:49
  • You shouldn't need to worry about the code coverage of the installed managed packages. Do any of your test cases use @SeeAllData=true or an older API version. There might be a validation rule or similar that is causing them to fail in production. Dec 1, 2013 at 20:54
  • I will post screen caps later when I get back, maybe that will help clear up the issues I'm running into. THanks btw.
    – fourq
    Dec 1, 2013 at 21:01

4 Answers 4


Managed package tests are only run in the following scenarios:

  • On package upload (only applicable to the package author)
  • If explicitly selected to run (changing the namespace on the run dialog for Setup > Develop > Apex Test Execution, dev console, specific API calls to run them, like setting runTests in the metadata API deploy call).
  • On metadata API deployments that have the runAllTests flag set to true (see the runAllTests description).

There have been situations in the past where managed tests run outside of these and all were deemed bugs and fixed. They do not ever run on change set deployments, although if there are managed triggers on objects your tests invoke those managed triggers will be run.

  • 2
    It was in fact that I had runAllTests=true in my deploy scripts. Removing this resolved my issue. Thanks for the explanation.
    – fourq
    Dec 2, 2013 at 18:01

If you want to run all tests but the managed packages tests, you can use something like that:

public with sharing class AdministrationTools {
public static PageReference startLocalTests() {
List<List<ApexClass>> searchList = [FIND '@isTest' IN ALL FIELDS RETURNING ApexClass (Id WHERE NamespacePrefix = NULL AND Status = 'Active')];
ApexTestQueueItem[] queueItems = new List<ApexTestQueueItem>();
for(ApexClass myResults : searchList[0]) {
   queueItems.add(new ApexTestQueueItem(ApexClassId=myResults.Id));
insert queueItems;
PageReference newocp = new PageReference('/ui/setup/apex/ApexTestQueuePage');
       return newocp;

Then just you can call it via Anonymous or using an administrator Apex page like:

<apex:page controller="AdministrationTools">
        <apex:commandButton action="{!startLocalTests}" value="Start local tests" />

Couple of things to point out regarding managed packages:

  1. There is no way to get details on the code that is failing in a managed package. This is done presumably to protect the IP of the creator

  2. If the tests are failing in your development org but not in production make sure that you have copied the necessary custom settings from production. It's common that managed packages depend on custom settings for their configuration. (I believe Salesforce was going to make the change that custom settings get copied from production to sandboxes when creating the sandbox, but I'm not sure in which release that was going to happen)

  • 2
    #1 is absolutley NOT true. From the metadata API docs (salesforce.com/us/developer/docs/api_meta/Content/…): "For deployment to a production organization, all tests, except for those that originate from installed managed packages, are automatically run". Managed tests are only run if specifically requested via the runAllTests flag in the mdapi, and NEVER by change sets. Dec 2, 2013 at 17:48
  • It's an incredibly confusing and poorly documented area, not surprised there's lots of misinformation because the actual working are so counter-intuative! Dec 2, 2013 at 18:01

I had this problem in one of my projects. The problem is that when you test your code managed code is triggerd. Even if you don't want to. Like, you insert/update/delete smth that has trigger in managed package. That triggers it's code and for some reason it fails. Actually in my case there were governor limits in their package. I refactor my code a bit so their code don't hit the limit. Also they have nullpointer. We contacted them and they fixed that problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .