function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
karthik Jonnalagaddakarthik Jonnalagadda 

Code coverage issue

Hello All,

I Have CreateNewLead class and CreateNewLeadTest classes. I run the test class it showing test is passes but Code Coverage 0% (0/20). What was the reson Please help out . code bellow.
global class CreateNewLead


global static void NewLead()

 RestRequest req = RestContext.request;

        String bdy = req.requestBody.toString();
         new_member_registration member = (new_member_registration)JSON.Deserialize(bdy,new_member_registration.class);
          List<Lead> NoLeads=[Select ID from Lead where Offerboard_Member_ID__c=: member.memberId];
          Lead l = New Lead();
            if(String.isNotBlank(member.firstName) && String.isNotEmpty(member.firstName))
               l.FirstName = member.firstName;
                if(String.isNotBlank(member.lastName) && String.isNotEmpty(member.lastName))
                l.LastName = member.lastName;
                 if(String.isNotBlank(member.memberId) && String.isNotEmpty(member.memberId))
                l.Offerboard_Member_ID__c = member.memberId;
                 if(String.isNotBlank(member.companyName) && String.isNotEmpty(member.companyName))
                l.Company = member.companyName;
                 if(String.isNotBlank(member.memberType) && String.isNotEmpty(member.memberType))
                l.Member_Type__c = member.memberType;
                 if(String.isNotBlank( && String.isNotEmpty(
                l.Email =;
                if(String.isNotBlank( && String.isNotEmpty(
                l.Phone =;                 
                l.Date_Member_Joined__c = member.datejoined == null ? null :;
                Database.SaveResult sr;          
                sr = database.insert(l,false);
                sr = database.update(l,false);          
catch(Exception ex)
system.debug('ERROR: '+ex.getMessage());


  public class new_member_registration{
    public String memberId;
    public String memberType;
    public String firstName;
    public String lastName;
    public String companyName;
    public String email;
    public DateTime datejoined;
    public String phone;


Test Class  code
Private class CreateNewLeadTest {
  testmethod Private static void TestCreateNewLead()
        Lead ObjLead=new Lead(FirstName ='karthik-test',LastName ='reddy-Test',Offerboard_Member_ID__c ='1234567',Company ='Test-Company',Member_Type__c ='Investor',Email ='',Phone ='9032793424',;
        Insert ObjLead;
        Lead L=[select Offerboard_Member_ID__c from lead where];
        system.assertEquals(L.Id, ObjLead.Id);

Andy BoettcherAndy Boettcher
Is there a trigger in play here?  You're just doing a basic DML in your test class - your main class is a REST service.  To test a REST service, you need to assemble a RestRequest and pass it to the service.