2

I have a test that takes about 5 minutes to run during production deployment.

If you just click "run test" or run it from execute anonymous, it's not slow at all (a few seconds).

Is there a way to get the log from a deployment test-run to see what's taking so long? Anyone have any suggestions of things to look at that are known to cause extreme slowness?

Deployment is via ant, if that matters at all.

Extra info based on comments...most of the complex tests have "seeAllData". The data model is very, very complex and it's very valuable to test on the real stuff.

With the new spring14 deployment monitor, you can tell exactly what the offending test is.

7
  • 1
    Are you sure it is just the one test that is slow? Whenever you deploy to prod, all tests run every time even if you aren't redeploying them Commented Mar 20, 2014 at 16:19
  • Adding my 2 cents apex tests run even if you try to validate which takes the same time as deploy, only that the validation is a pre step that helps you make sure you do not get to see surprises during deploy. My org has upto 400 test classes and takes painful 55 mins to 80 mins to validate or deploy any component.
    – Rao
    Commented Mar 20, 2014 at 16:36
  • 1
    How many of your tests are relying on "SeeAllData" or the equivalent?
    – joshbirk
    Commented Mar 20, 2014 at 20:29
  • added answers for Danial and Josh up in the original question. Commented Mar 23, 2014 at 4:13
  • @joshbirk what's the impact of seeAllData? What types of problems can it cause that might explain why the one test runs so slowly? Commented Mar 26, 2014 at 4:47

2 Answers 2

1

It's possible the issue is the difference in parallel vs serial execution of tests. To my knowledge, the ant deployments run tests serially. However, the web UI enables and I think defaults to running tests in parallel. If you have a lot of fast tests, it's possible your deployment tests take longer just because they run one at a time.

Since the Ant Migration Tool just calls the Metadata API's deploy method, the impact should be the same on all tools which deploy through the Metadata API.

3
  • Good thoughts...I normally run tests from mavens or the dev console, so maybe it's a metadata api vs tooling api thing. I'll see if I can get that super-slow test to run via the metadata api and see whether it still takes minutes. Commented Mar 27, 2014 at 3:05
  • To my understanding, the tool api tests are called in parallel. I know the dev console can run in parallel but I'm not sure about how mavens handles test execution. Commented Mar 27, 2014 at 17:31
  • Oops, hit enter when typing... To test the individual test through the metadata api, you can use deploy a blank package (no metadata with a skeleton package.xml like this github.com/SalesforceFoundation/Cumulus/tree/dev/lib/empty) and use the run Commented Mar 27, 2014 at 18:04
0

Deploying to production runs all unmanaged apex unit tests. This is to ensure that your new code does not break your production "build".

1
  • yep, I get it. question is about performance of a single test during deploy. Commented Mar 23, 2014 at 4:13

You must log in to answer this question.

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