0

Is it possible to exclude running the managed package test classes and only run my own org's test classes at the time of deployment using ant script?

2

runAllTests parameter is your friend. Look at the DeployOptions in the metadata API documentation. It states that:

If true, all Apex tests defined in the organization are run.
For deployment to a production organization, all tests, except for those that originate from installed managed packages, are automatically run regardless of this argument. If any of the tests fail when the rollbackOnError parameter is set to true, the entire deployment will roll back.

So, if you simply specify runAllTests = false in your deploy call, managed package classes are automatically excluded and all your unmanaged classes are executed. If you are not migrating to a production Org, you can even turn unmanaged classes execution off but it is not possible for a production Org deploy.

Hope this helps.

  • I saw that comment in the documentation, I wanted to deploy the code from my developer sandbox to a CI sandbox and wanted to EXCLUDE the managed package test classes. runAllTests=false did not change anything.I achieved it using <RunTest> but had to handcode each test class, which i wanted to avoid. – Shalini SF Apr 7 '15 at 7:07
  • @Shalini, Individually listing the unmanaged classes using runTest will work only for "to sandbox" migrations. If your destination is a production Org, this setting is conveniently ignored and salesforce will force-execute all unmanaged test classes. – Sridhar Apr 7 '15 at 15:52
  • As I understood from the Metadata API documentation , runAllTests= false during production deployment excludes all the managed package test classes which is what i would intend to do, so this option should work for production deployment and i can use the <RunTest> option to deploy to SB. Do you have a better way in mind? – Shalini SF Apr 8 '15 at 0:29
  • I think you can safely leave the runAllTests=false option out even from the production deployment and it will do the same thing (run all unmanaged tests and exclude the managed classes). If you want to run the unmanaged tests in sandbox, the only way is to use the runTest option. So, your method is sound. – Sridhar Apr 8 '15 at 17:05
  • Thanks for the confirmation, feel more confident to implement it now. – Shalini SF Apr 8 '15 at 23:15

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.