8

For the past month or so, I've noticed that when I execute some (not all) unit tests from within the Developer Console, sometimes the Status for folders display as failing (red X) even if/when all the containing methods display as pass (green check).

How can/should such failures be understood and resolved?

All individual tests pass (green tick) but test folder shows fail (red x)

  • I have noticed this too - a situation where all the tests pass but the overall folder still shows the red X. I believe it is just a "quirk" of the current developer console release. I've been able to deploy to production with these test classes. – Doug B Nov 22 '13 at 14:23
  • 1
    I've also successfully deployed... but would like to at least understand if I am accepting any risks by doing so. – Brian Kessler Nov 22 '13 at 14:54
  • 1
    I've added a pic for clarity. Is this the issue you mean? The tests all pass but the folder suggests otherwise? – Doug B Nov 22 '13 at 15:06
  • @DougB I think it's actually a tooling API fault when it encounters old style coverage data. See my answer for more detail, but I've hit a very similar issue outside the dev console. – ca_peterson Nov 22 '13 at 19:33
  • @DougB, cheers for adding the pick; I should have done that. Exactly what I meant. :-) – Brian Kessler Nov 22 '13 at 20:47
7

I've seen this issue in a number of orgs and it's always been related to the issues resulting from backend changes to the code coverage system. The apex PM lays out a fair bit of detail on the developer.force.com blog: http://blogs.developerforce.com/engineering/2013/11/code-coverage-and-the-force-com-developer-console.html

When looking at the Setup > Develop > Apex Test Execution screen does it show it failed with the error "Could not run tests on class {id}" then this is the same issue.

To resolve: click the "View Test History" link on this page, then press the "Clear Test Results" button as many times as it takes to purge all the history. This can take more than a few minutes, depending on the org.

After that try re-running your tests and all should be well.

| improve this answer | |
  • 2
    Correct. For just a little more explanation: This happens when there is an exception on Salesforce's side. i.e. the tests methods pass, but then an exception happens when cleaning up, storing code coverage, setting values on the test result object, etc. The exception causes the overall test run to fail. Unfortunately, the error ID doesn't seem to be propagated through the API. If you still see this problem after clearing your code coverage, you should file a case so support can find the exception associated with your org ID and report it to R&D. – Thomas Nov 22 '13 at 19:37
  • @CA_Peterson and Thomas, cheers for the great info! – Brian Kessler Nov 22 '13 at 20:48
  • @BrianKessler did this fix things for you? If so, would love for you to accept it. – ca_peterson Nov 23 '13 at 0:17
  • @ca_peterson that worked for me - interesting link to that blog, thanks. – Doug B Nov 23 '13 at 10:48
  • @Ca_peterson, I'm not currently observing the problem, so I think it's fixed. :-) – Brian Kessler Nov 23 '13 at 12:23
1

Check the log to see if other classes or triggers which also execute as a result of your test class running have failed. This can sometimes occur and will cause your test class to also fail even if the class or trigger your test class is intended to test is passing. In essence, anything else which fails or creates an exception while your test class is running can cause your test class to fail.

| improve this answer | |
  • I'm not entirely certain I follow. I would expect a failure in the testMethod if something within the testMethod fails. Do you mean failures from concurrently executed test Classes? But, aside from such being disorderly, I've seen test classes fail even when they run alone and the methods pass. – Brian Kessler Nov 22 '13 at 14:49
  • No, I mean failures form concurrently running classes or triggers that are instantiated by the code from the Test Class. In some cases I've seen, one operation can cause multiple triggers to fire, even though the class is intended to only test one of them. If one of the other triggers causes an exception, the entire Test Class can fail. – crmprogdev Nov 22 '13 at 14:54
  • 1
    @crmprojdev But that would still fail the test. The inquiry is about the tests itself passing but the class being marked with a "failed" mark, which by definition shouldn't occur. – sfdcfox Nov 22 '13 at 17:10
  • Actually, in the example I gave, depending on when and where the exception occurs, I've seen the test class pass the test because it didn't necessarily depend on the other triggers or classes. However, overall, this type of thing can cause a failure during deployment. – crmprogdev Nov 22 '13 at 19:04
1

This appears to be a bug. I would recommend contacting support to see if it has been logged, and also check the Known Issues page.

| improve this answer | |

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.