4

So pretty much what topic says. While trying to upload a package I get the following error:

Package upload error

However, when I check test coverage anywhere else, it shows me 77%.

Developer console:

Dev console test coverage

Setup --> Develop --> Apex Classes:

develop apex classes test coverage

And Sublime Text with MavensMate:

MavensMate test coverage

I've seen this question as well, but the problem is that I did include all classes into my package, so all test classes are in this package as well.

Also, while I was testing I raised overall coverage by about 10%(from 50% to 60% I think), then added that class into the package, but package coverage only went up by about 2%. And going from 60% to 77% gave me about 4-5% of test coverage according to the package uploader.

Am I missing something? As I mentioned previously, all classes and triggers are in the package. Or is it just some bug that I should report to Salesforce?

5
  • Try clearing the Test history and then running all the test cases again. You can do this under App Setup > Develop > Apex Test Execution > View Test History and then Clear Test Data. There might be older test run data that is pushing the figure up. The packaging process runs all the included tests from scratch to calculate the coverage. – Daniel Ballinger Dec 18 '14 at 19:10
  • @DanielBallinger thanks for your comment, but that was pretty much the very first thing I did – Novarg Dec 19 '14 at 6:35
  • OK, that is one thing ruled out. Is there anything interesting about your test cases? E.g. Do they have a depandancy on a particular user or custom setting. Could running them in parallel cause issues due to the use of for update? If you put a System.assert(false, 'Boom'); at the end of a test case does it fail as expected in the package uploader. Or put the assertions in the code that should be covered but doesn't appear to be. – Daniel Ballinger Dec 19 '14 at 9:21
  • @DanielBallinger normally not. And System.assert(false, 'Boom'); does make upload to fail. Message is One or more Apex tests failed. Resolve the test failures, then upload again., so pretty much as expected I guess. Could you please explain a bit more the running in parallel part please? – Novarg Dec 19 '14 at 13:19
  • You can see details about parallel testing in UNABLE_TO_LOCK_ROW error while running all apex test classes. It would need to be combined with exception handling in the test methods to cause an issue. If your false assertions are being hit at the end of the test methods then they are running to completion as expected. Are you able to add a sample of one of your test methods to the question? – Daniel Ballinger Dec 20 '14 at 8:44
2

Found what was wrong with my coverage. There were no test classes written for a part of the project, so those classes never got called in any test class which lead to them being omitted from the list of classes covered and therefore them not being counted towards Overall coverage.

However, while uploading a package, after tests were run some classes didn't have any coverage at all which lead to Overall coverage being so low.

After writing a few more test classes(for the classes that were not tested), I got the coverage above 75%.

So if there are no test classes testing some class A, then this class A will neither show up in Overall Code Coverage class list, neither count towards it.

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.