Why the coverage code is 0?

global with sharing class OutputControllerMap {

    global static List<Output__c> findAll() {
        return [SELECT Id, Name, Project_Type__c,Beneficiary_Full_Name__c, Commune_del__c,  Departement_del__c,     Locality__c, GPS__Latitude__s, GPS__Longitude__s
                    FROM Output__c];


Test class

public class OutputControllerMapTest
  static testMethod void OutputControllerMapTest()

   Project__c p = new Project__c();
   p.Departement__c = 'OUEST';
   p.Project_Name__c = 'Test Mappp';
   p.Type_Of_Request__c = 'Collective';
   p.Department_FFP__c = 'Agriculture';

   insert p;
   Milestone_s_Type__c mt = new Milestone_s_Type__c();
   mt.Name = 'House';

   insert mt;

   Milestone__c m = new Milestone__c();
   m.MilestoneCategory__c= 'Other';
   m.Milestone_s_Type__c = mt.Id;
   m.Target_number__c =20;

   insert m;

 Output__c o = new Output__c();
   o.Milestone__c = m.id;
    o.Locality__c = 'jklhjlhkjlhjlhkl';
 o.Project_Type__c ='House';
 o.Departement_del__c ='Ouest';
 o.Locality__c ='Leogane';
 o.Commune_del__c ='Leogane';
 o.GPS__Latitude__s =12.7545;
 o.GPS__Longitude__s =-72.54;
  Insert o;

   Test.setCurrentPageReference(new PageReference('OutputControllerMap')); 

   OutputController oc = new OutputController();


  • 1
    You may find some valuable resources linked from our collection of canonical questions, many of which have to do with unit testing and code coverage.
    – David Reed
    Feb 21, 2019 at 16:47

1 Answer 1


Code coverage is derived by running the code. Since your test never calls findAll(), it cannot provide any coverage for this method. I recommend you work your way through the Trailhead module on Getting Started with Apex Unit Tests to better understand the basics of how unit tests work.

  • Can you modify it an call it for me please? Feb 21, 2019 at 16:41
  • You just need to call the method statically. OutputControllerMap.findAll(). If you do not know how to call a method in Apex, you may also want to check out Getting Started with Apex.
    – Adrian Larson
    Feb 21, 2019 at 16:43

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