+ Start a Discussion

Help: Can't get over the 75% test coverage



I'm relatively new to Salesforce/Apex, and currently having problem getting the 75% test coverage.


FYI, I've customised the LMA's Licence object to include a few custom fields for our application. In doing so, I had to also create the following pages/classes - just to be consistent with the LMA's look-and-feel:


1) A Visualforce page - a modified version of the LMA's Modify Licence page. This is to allow me to edit my custom fields

2) A "duplicate" version of the LMA's statusPicklistExtension for my new page. I tried to use the LMA's extension but got an error saying that the class is "not marked as global and cannot be used as a controller or extension". I basically guessed what the extension does based on Status flow diagram in the LMA demo. Not sure if this is right though!


Now, I have also written the test methods and they do give me 100% coverage for every one of my Apex classes. But the overall coverage is still only at 64%.





Test ClassAcxTrackingTests
Tests Run2
Test Failures0
Code Coverage Total %64
Total Time (ms)1127.0



Code Coverage



 The Code Coverage section shows that I only get only 2% for the class TestLicenceseUpdates. But this test class belongs to the LMA. So, could this be dragging my test coverage down? And if so, how can I fix it?


I just remembered I have an another 'exception' class which extends Exception, and doesn't have any additional code. So I don't think it matters if I don't write any test for it.


Any help would be very much appreciated.







I have no idea what LMA is but I would imagine if Sales Force is telling you that a class only has 2% coverage that you have not choice but to write tests for it.






From my understanding, the class TestLicenseUpdates contains the test methods for the LMA application. It would be rather strange if I had to write test methods for "test methods". And even if I wanted to, I would still not be able to do it because that class is not "global" - I cannot see the code.


FYI, LMA is Salesforce's licence management application. You can search and view the demo on AppExchange.




I would think even if you can't see the code you should be able to create an object of the type and call the methods on it.


No documentation/support etc for that application?


I cannot use that class in anyway - it's not global.


No documentation that I've found to be useful.


Send an email to salesforce.com and they said I should post my issue to this forum.


Thanks for the suggestion nevertheless.


For anyone interested, I've found a work around. It's not nice, but it gets me over the line.


I basically created enough dummy "test" code, 40 lines of dummy if/else if in fact, to cause my overall code to out weigh the LMA test class, in terms of test coverage.My test coverage is now at 77%. Some more dummy code and I should get 100%!!!!