I have a managed package which is going to be installed in several enterprise orgs.

Salesforce while deployment all unit tests will be run and if they all success with 75% code coverage then only you can deploy.

My question is "Do all tests run in dev org only or they also run enterprise org while installing the package?"

  • Is that a 3rd party package? or you are writing it? – Saariko Sep 25 '12 at 6:33
  • I am writing it. – doga Sep 25 '12 at 6:41
  • 1
    Are you deploying your managed package, or installing it? – zachelrath Sep 25 '12 at 12:02

Whenever you deploy managed package code, your tests will always be executed against the target org you are deploying into.

If you are installing your managed package into another org, then your tests will only be executed against the target org if you explicitly request them to be run on install using the @isTest(OnInstall=true) annotation.

| improve this answer | |
  • What do you mean by "deploying" a managed package? There used to be a deploy button but this did not run tests, it just changed the custom objects from "In Development" to "Deployed". This was removed a few releases ago. – ca_peterson Sep 25 '12 at 17:05
  • Since the question's author (@doga) used the phrase "deploy managed package", which is ambiguous, I took the question to be referring to either of 2 things: (1) Deploying code (using Change Sets / IDE / Ant, etc.) that is included in a managed package dev org into another org (perhaps for creating a new package, forking the code, etc.) (2) Installing a managed package version into an org – zachelrath Sep 27 '12 at 17:30
  • @zachelrath so on installing a managed package salesforce doesn't run tests. Does this mean that if I am successfully able to upload a managed package from dev org then this will install in target org for sure without any problem? – doga May 18 '13 at 13:06

75% test coverage is required for all classes included in your managed package application.

When you add components(apex classes, triggers etc) to package, then test coverage for all these classes is calculated and not all of your developer org classes.

Hope this helps :)

| improve this answer | |

If you ask : will my test run be executed on the dev environment only? the answer is NO, it will also be executed when deploying to the prod env.

When deploying your package to the production env, your test class/functions are executed as well.

Always remember to use test data correctly

| improve this answer | |
  • 5
    This is wrong. Managed package tests are only executed if they have the @isTest(OnInstall=true) annotation on them. By default no managed packaged apex tests are run on package install. Instead they are run in the dev org when the package is uploaded. – ca_peterson Sep 25 '12 at 16:58
  • when uploaded you mean: deployed? – Saariko Sep 25 '12 at 17:04
  • 1
    There is no concept of deployment in managed package development as far as I'm aware. The button to create a package is labeled "Upload" - and this is when apex tests are run on the packaged code. – ca_peterson Sep 25 '12 at 17:06
  • 2
    @kibitzer I just published a test managed package where every single test fails on install and it installed successfully into a test org. I've been working with them for years and they really don't run tests on install, I promise! – ca_peterson Sep 27 '12 at 17:35
  • 1
    Agreed with ca_peterson. If @doga is referring to installing a managed package, then the answer to his question is NO, tests will NOT be executed when installing a managed package into an org (unless @isTest(OnInstall=true). But if the author is referring to deploying code (using Change Sets, IDE, Ant) that is included in a managed package dev org into another org (perhaps to branch the code), then the answer is YES, ALL tests in the destination org (including BOTH those in the code being transferred and tests already in the destination org) WILL be run. – zachelrath Sep 27 '12 at 17:38

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.