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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following code: and Salesforce says that with my two test cases I only have 42% coverage.

I feel I should have more, but it's not showing the latter part of the class, the part dealing with product areas and product categories, as being covered at all, which suggests to me that it is not actually seeing the linkage between the product and the contact by the line item object.

How would I put in assertions to confirm that my linkage is being made correctly? And if the assertions show up an issue, how would I resolve it?

Thanks for any assistance you are able to provide.

share|improve this question
up vote 1 down vote accepted

It may be that exceptions are being thrown during the test cases and then converted into page messages by the handling code.

Try adding assertions after your Test.stopTest(); lines.

System.assert(!ApexPages.hasMessages(), ApexPages.getMessages());
share|improve this answer
Thanks. There were exceptions that were being turned into page messages. This is a helpful trick, so marking as the accepted answer, though I just figured it out by trial-and-error. – Evan Donovan Dec 12 '12 at 22:40
No problem, glad you got it sorted. I'd suggest adding some more assertions to your test cases to get the full benefit from them. E.g. check that the totalFUAHrs property has the expected value based on the input test data. – Daniel Ballinger Dec 12 '12 at 22:44

Your Answer


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.