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
kevoharakevohara 

IDE test class static block silent failure issue

I am using v24.0 of the IDE. I have some test classes that have some initilization code in a static block. In this block I am inserting a record. I realized after the fact that I was not setting a required field on the record I was inserting. The odd thing is that this insert is failing silently and not showing an error. This behavior started after I updated the IDE to v24. v23 shows the uncaught exception as it should.

 

Has anyone else experienced this issue? When I open up the Test Runner Debug Log I can see the exception but I am not being prompted like in the past. This is making debugging really hard.

 

P.S. Before someone asks, I am not wrapping this in a try/catch block. :)

Best Answer chosen by Admin (Salesforce Developers) 
dcelldcell

We are having this problem also, and have reported it to SFDC.

I just got update from T-3 engineer and he informed me that the issue you reported has been considered known issue with our product development team.

They are working on this issue to resolve it ASAP.

You can follow the latest updates regarding this issue at

http://success.salesforce.com/issues_view?id=a1p30000000SDTcAAO

 

Case Number:

07686908

Problem Type:

Development

Product Topics:

Apex and Visualforce

Case Subject:

Exceptions not fatal in static sections of test classes -Version 24 (Spring 2012)

Severity Level:

Level 3 - High

Case Description:

Spring '12 (24) introduced a bug. If a static section in a test class encounters an exception, this will not abort the test class run, or even be reported when running the test class. Note that the metadata version of the test class is irrelevant. See below test class--it should report an error but does not, either with an Assert or a thrown exception: @isTest private class daveBugInTestClass { public class applicationException extends Exception {} static { System.assert(false); throw new applicationException('try to cause a test failure'); } static testMethod void testDebug1() { System.debug('I am in testDebug1'); System.assert(true); } }

Created By:

Dave Seligson

Created Date/Time:

06/05/2012 11:58:07 AM MST

All Answers

kevoharakevohara

Seriously, nobody else is seeing this? We just ran into this again! This has to be fixed asap. Can anyone from SFDC comment on this? I will be submitting a case today.

NortonMDNortonMD

We're definitely seeing it.  Can't confirm that the test run would short circuit from the static block prior to 24.0, but I'm fairly certain.

 

Any reply when you opened the bug?

kevoharakevohara

I actually never opened the case. I ran out of time. I will try to do it this week.

dcelldcell

We are having this problem also, and have reported it to SFDC.

I just got update from T-3 engineer and he informed me that the issue you reported has been considered known issue with our product development team.

They are working on this issue to resolve it ASAP.

You can follow the latest updates regarding this issue at

http://success.salesforce.com/issues_view?id=a1p30000000SDTcAAO

 

Case Number:

07686908

Problem Type:

Development

Product Topics:

Apex and Visualforce

Case Subject:

Exceptions not fatal in static sections of test classes -Version 24 (Spring 2012)

Severity Level:

Level 3 - High

Case Description:

Spring '12 (24) introduced a bug. If a static section in a test class encounters an exception, this will not abort the test class run, or even be reported when running the test class. Note that the metadata version of the test class is irrelevant. See below test class--it should report an error but does not, either with an Assert or a thrown exception: @isTest private class daveBugInTestClass { public class applicationException extends Exception {} static { System.assert(false); throw new applicationException('try to cause a test failure'); } static testMethod void testDebug1() { System.debug('I am in testDebug1'); System.assert(true); } }

Created By:

Dave Seligson

Created Date/Time:

06/05/2012 11:58:07 AM MST

This was selected as the best answer