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..
6 Answers
It appears that in latest Winter 2016 upgrade a bug was introduced where code coverage line highlights are missing from the Salesforce Developer Console
You can get them back by selecting the 'Test > Always Run Asynchronously' checkbox and re-running your test.
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.
-
i ran the same test methods in eclipse, it was covering that class. Aug 19, 2015 at 5:21
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.
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)
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');
MavensMate > Unit Testing > Show Apex Code Coverage For This Apex Class