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 the following code: http://codepad.org/AavgIrHB 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
add comment

1 Answer

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
add comment

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.