19

I ran the test classes from developer console but it didnt not show me the lines which are covered. Whenever we run the test classes in developer console it highlights the the lines which are covered and which are not covered in different colors. I cleared test data,Compiled all classes and then again ran test classes but it didnt work. In Code Coverage menu i am just getting one option that is 'None'. Please suggest..

7
  • I believe sometimes it has glitches. You can try using mavenmate's plugin for sublime to run tests there, looks like mavenmate's test execution always shows coverage correctly
    – Patlatus
    Aug 18, 2015 at 13:29
  • @Patlatus could you provide steps or may be help link of how to use it? Is it for IDE .. Thanks Aug 18, 2015 at 13:31
  • Download and install MavensMate, then from within Sublime Text click MavensMate > Unit Testing > Show Apex Code Coverage For This Apex Class
    – Rob
    Aug 18, 2015 at 13:38
  • Force.com IDE for Eclipse - run all tests will also give you code coverage
    – cropredy
    Aug 18, 2015 at 16:36
  • 2
    In case someone ends up here after Winter 16 upgrade - with Winter 16, there is a known issue that means you need to run the tests with the new "always run tests asynchronously" checkbox set to true in order to see code coverage... Oct 19, 2015 at 15:34

6 Answers 6

26

Go to the 'Apex Test Execution'and in option select list deselect the 'Store Only Aggregated Code Coverage' checkbox. enter image description here

8

It appears that in latest Winter 2016 upgrade a bug was introduced where code coverage line highlights are missing from the Salesforce Developer Console

salesforce-code-coverage-highlight-missing-fix

You can get them back by selecting the 'Test > Always Run Asynchronously' checkbox and re-running your test.

1

Make sure that your test class is covering the targeted class for which you have written the unit test methods.

none in top left dropdown is only displayed if there is no test method associated with the class which you have opened in dev console.

enter image description here

1
  • i ran the same test methods in eclipse, it was covering that class. Aug 19, 2015 at 5:21
1

For my case, for it to calculate, I had to launch the test class via build > Develop >Apex Test Execution. Then from the same screen, click on the developer console button.

1

The following solved the problem for me I hope it helps you as well:

  • Try to create a test suits in eclipse by going to: File > New > Apex Test Suite
  • The "Create New Apex Test Suite" pop-up window should open up
  • Now select the project you are working on
  • In the text input box that is labeled "Apex Test Suite Properties", insert an arbitrary name for your test suite
  • Click on Next and from the list of classes, select all the test classes that you need to run together (it can be just one class)
  • Click Finish
  • Now from "Run" menu select "Run Configurations" and the window will pop up
  • You should see three tabs called "Project", "Test", and "Common", select "Test"
  • now in the Test tab under "Select one or more test suites" section click on "Use suite" checkbox
  • you should see the name of the test suite you just created (there might be other test suites there)
  • click on the checkbox next to the name of the test suite that you created and want to run
  • Finnaly click on "Apply" then click on "Run", and it will run the test suite and now you should see the test coverage and results in the "Apex Test Results" tab (I'm assuming you already know how to access this tab)
0

The following solved this for me. I had created some test accounts but forgot to match the name to my query used in creating the controller. It took a while to spot that I wasn't creating the controller and, therefore, not testing my class.

Account a1;
List<Account> lstAccs = [select id,name Account where name = 'A test account'];
List<Account> result = new List<Account>();
if (lstAccs .size()>0){
   a1 = lstAccs [0];
   ApexPages.StandardController theCont = new ApexPages.StandardController(a1);
   myExtControllerClass theContExt = new myExtControllerClass (theCont);
   result = myExtControllerClass.getResultOrSomeSuchMethod();
}

If I hadn't also created the account in setup, it wouldn't calculate any code coverage.

Account anAcc1 = new Account(name='A test account');

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .