function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ken KoellnerKen Koellner 

Execeding long deployment times because of Apex test time

Are deployments are starting to take an exceedingly long amount of time.  We have about 600 apex tests and it's now taking hours to run them.  Since we need to do several validations to flush out any deployment issues, it's really putting a damper on our release cycle.

 

Anyone else have this problem?

 

 

What I've noticed looking at some logs of tests is a huge amount of time is spent inserting test data.  I know it's best practice to insert data specifically for testing rather than rely on data alredy there.  But, it is take many seconds just to insert and Account.  More than half of that is territory processing.

 

I don't want to have to rewrite all our tests to work of data already in the database but I want to come up with some way to speed up the validation.

 

TejTej

We had that issue.

We have rewritten the classes that are taking the longest times to run. we made sure that those classes will only work with the test data we created in the test class not the org data.

 

if those are the batch classes we used if(Test.isrunningTest()) to put the limit on the query's like to only process couple of records.

 we have almost 450 tests that will take around 20 min so far (touch wood).

 

 

Ken KoellnerKen Koellner

Interesting.  I find just the opposite.  When sample test I have runs in 15-30 seconds when inserting data (Account) and a 1/2 second if I select a couple Accounts out of the org.

 

What I haven't tried yet is the API 24.0 feature where no org data is visible to the test.  I need to try that experiment next.

 

It may just be that we have so much Account and Opportunity trigger logic and Account territory rules that inserts are always going to be expensive.

rocwilcoxrocwilcox

Are you deploying via the force.com ant migration tool?

Since you indicate you need to do several 'deployments" to flush out problems.  You could use the ant deploy's option to "check only".  It wont deploy anything but will validate the deployment.  You can run this everyday during your "release cycle" and find out about problems up front and resolve them, so that when you go to do actual deploy you'll only have to do it once.

 

 

cmendlercmendler

You can do the same with the IDE.  I assume the OP knows this.  The validation/check only time is the same as the actual deployment time.  It does not address the issue of the lengthy time to run all tests.

 

There are a few release pilot programs that will allow selective deployments and not run all tests (FINALLY!), but they are only in beta right now, I think.  You can contact your support rep to see about signing up

Ken KoellnerKen Koellner

We are using the ant deployment tool.

 

When I say deployment i'm including validations.  We do many check-only validations until we get a clean run of our package.  Then we do the actual deployment.

 

 

Right now, I think the main culprit may be territory rules.  We're inserting test data including Accounts and a huge amount of time is processing the territory rules on the Account inserts.

 

-K