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
champ_vimalchamp_vimal 

System.Async Exception : Test failures when I run all tests

Hi,

 

I have created some batch apex code alongwith other triggers and class/controller codes. 

 

When I run individual test methods on them, I am able to get test success result alongwith nice code coverage %. However when I run all tests together, I get following test failure errors:-

 

1)System.AsyncException: Database.executeBatch cannot be called from a batch or future method.

2)System.AsyncException: Future method cannot be called from a future method: changeOwners(String, String)

3)System.AsyncException: Future method cannot be called from a future method: getLead_Rollup_Amount(Id)

4)System.AsyncException: Future method cannot be called from a future method: changeOwners(String, String)

 

Please note again that the exceptions dont come when tested individually.

 

Please advise on same.

 

 

Thanks,

 

Vimal 

Best Answer chosen by Admin (Salesforce Developers) 
TehNrdTehNrd

champ_vimal wrote:

Does anyone have idea on what was the cause of issue and what were the steps followed to resolve them?

 


It was an issue on salesforce.com's end. There was nothing required on the user side to fix this issue.

All Answers

jhartfieldjhartfield

I too am having the same problem and it just started this morning.  I can also get them to fail occasionally if I run them individually, but they always fail when I run them all at once.  We have made no changes to our code and they used to work just fine.

 

To be clear, the only tests that are failing are the ones that involve starting a batch job, giving the same 'async' error described above.  This happens for EVERY test that involves batch jobs and occurs across the different ORGs that we have set up.

Message Edited by jhartfield on 12-10-2009 02:13 PM
JPClarkJPClark
Great, right when we're trying to move to production.
thoban2thoban2

We are seeing the same issue today on a unit test we've had in place for several months.   The test runs fine if we run it individually.  We are also fine when we run tests for ALL classes from the ide.  But when we run tests for all classes from the browser based development environment, it fails.

 

 

4larryj4larryj
Same for our org as well.  Tests pass from the IDE, but fail on a deploy using the ant migration tool.
kevinbnpowerkevinbnpower
Same error on deploy.  Looks like SF may be having some issues... anybody out there?
avideoncrmdevavideoncrmdev
Same problem.  Just started today!
JuanBessJuanBess

Yes, i start hitting the same issues this morning. I think is a Salesforce bug related to the new release. So i hope to have some solution shortly because i need to package my application and this is blocking me.

 

J.

trublutrublu

any words, guys?

 

I am dead in the water with this problem.

 

did they fix it?

 

thanks!!!

neoocmwtfneoocmwtf

I'm also dead with this! I had planned to build a release package today!

HELP! HELP! :manmad:

SteveFromTLSteveFromTL
Same problem here as well.
JustinCJustinC

I'm having the same problems with "Database.executeBatch cannot be called from a batch or future method.".

 

Here's what I've found which seems consistent with others:

  • Running all unit tests will cause this error
  • Running one unit test seems to work fine
  • Running the actual code outside of unit testing works fine - so the batch actually executes properly

Justin
aaronbaaronb
Called support today, they didn't immediately know if this was a more widespread problem. This board seems to be more on top of things. Seems to have started on Dec 9 in the evening Pacific time when we first experienced it. They did say there was a patch released on Wed.

JPClarkJPClark

I opened a case for this yesterday morning when we realized that it was more than just us.

But they just contacted me saying they are looking at it this afternoon.

 

 

swidandbswidandb
We have also run into the same issue and created a case. Pretty much can't deploy. We escalated our case.
spraetzspraetz

We have a bug created for this problem and are looking at it now.  It only occurs when you execute more than one executeBatch in a runTests request. 

 

No ETA on fix, but this is a high priority.

kivacailinannekivacailinanne
Ditto.
TehNrdTehNrd
I am getting a similar issue with @future methods in tests. Tests run fine individually but fail with Run All Tests. My error is can't call future method from future method but my code doesn't. This worked fine a few weeks ago and I have made no changes in over a month.
Message Edited by TehNrd on 12-11-2009 04:03 PM
sf42_Tobisf42_Tobi

Same problem with two batches.

I tried with separate test classes, separate test methods, but only when each batch is tested separately, the tests run without an error. No difference running test in IDE or browser.

bleeblee

Hi all -

 

Apparently this is a known issue with SFDC support and they will have a e-patch by today 12/14 or 12/15.   Here's hoping this is true....there was a problem with the async object

 

tmatthiesentmatthiesen
We are on schedule to resolve this issue tonight.
G_MitchG_Mitch
The fix worked great for me. No problems deploying after it was applied!
JustinCJustinC
I haven't done a lot of testing yet, but seems to be working fine for me as well.
avideoncrmdevavideoncrmdev
the fix worked for me too!
TehNrdTehNrd
Looks like this also fixed the issue where you got an error saying an @future method was called from an @future method when indeed it was not.
champ_vimalchamp_vimal

Does anyone have idea on what was the cause of issue and what were the steps followed to resolve them?

 

 

Thanks,

 

Vimal 

TehNrdTehNrd

champ_vimal wrote:

Does anyone have idea on what was the cause of issue and what were the steps followed to resolve them?

 


It was an issue on salesforce.com's end. There was nothing required on the user side to fix this issue.

This was selected as the best answer
Wim VelzeboerWim Velzeboer

Could this be caused by record locking? I am experiencing the same issue, but mostly with Bulk tests. They are giving a "Apex CPU time limit exceeded" error. So I figured, when I try to save a record and another test is holding a temporally record lock, then my bulk test is waiting until it is released (or timed-out), the sum of all that waiting for released record lockes could cause my Bulk test to fail. 

The real question is then: do Unit Test Classes affect the record locking for eachother?