Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I have a whole slew of testMethods in an AccountTriggerHandlerTest class. When I run the class as a whole, I get about 60% coverage, and it shows me that I'm missing one of my trigger methods. However, when I run the testMethod that exclusively applies to covering that trigger method, it correctly shows that it covers that testMethod. Why would it not cover it when run in aggregate but cover it when run in isolation? I have parallel testing disabled...

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Are you relying on specific data in the org? (i.e. using seeAllData=true). If so, that could be interfering if something else is updating a record that trigger is also using. Sounds more like a problem (bug) with the test coverage reporting though; I suspect in cases where it's vital (i.e. deploying) the coverage will be calculated correctly.

share|improve this answer
    
No, I never use seeAllData=true... It did deploy fair enough, but my other coverage was high enough that it wouldn't have made a difference either way. The odd thing is that even in production, when I "Run All Tests" it still shows the low coverage on that class... –  Nathan Williams Mar 31 at 1:16
1  
There's been heaps of issues with reporting of code coverage recently. Maybe try moving that method to a different class to see if the results are more reliable? –  LaceySnr Mar 31 at 1:22
    
Sadly, that was the answer... 100% code coverage now. Seems sloppy of salesforce to force that. I'm not happy with class skew simply because their algorithms don't work properly... –  Nathan Williams Mar 31 at 14:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.