[SalesForce] Why do Apex Unit Test CLASSES sometimes FAIL when all the contained METHODS PASS

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)

Best Answer

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.

Related Topic