I’m having a very odd issue pop up wherein if I put all 75 of my account testMethods in one class, I get less than stellar coverage (maybe 70%) but if I split those testMethods up into 8-10 smaller classes (same 75, but split) then I get higher coverage (upwards of 90-95%)
This is in the sandbox
Is this just a glitch in the way they calculate code coverage in test? Or is this actually something I need to pay attention to and not allow more than x testMethods per class?
Distilling the comments:
- Clear out all the test coverage and try running it all from scratch. There can be caching issues with previous test runs. See How to eliminate bad code coverage data for apex classes ?
- Avoid the “Store Only Aggregated Code Coverage” option for test runs unless your volume of tests requires it.
- Consider disabling parallel testing. Also accessible via the Apex Test Execution Options page.
- Compile all the classes before running the tests.
- Check that the API versions for the test class and the class being tested are the same.
If those steps fail you, raise a support case with Salesforce.