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
Shruthi NarsiShruthi Narsi 

Test class failing in prod. Can anyone help me use best practises

I have written a test class to add list of leads and display on account page the lead should be of record type Partner Lead Registration.The test class code coverage is 90% in sandbox. While deploying its showing code coverage is 0% can anyone rewrite the test class to deploy the code successfully in prod

Below is the code I have writtena and the test class code covergae is 90%. Can anyone make the changes in the code so that ot gets deployed in prod. Error says test class code covergae is 0

Apex class

public  class PartnerLeadController {
    public Account acc{get;set;}
    public List<Lead> LeadList{get;set;}  
    Set<String> UserContactId = new Set<String>(); 
    public PartnerLeadController(ApexPages.StandardController stdController) {
        LeadList = new List<Lead>();
        this.acc = (Account)stdController.getRecord();
        list<contact> conlist=[Select Id From Contact WHERE AccountId =:acc.Id]; 
        for(User u: [Select Id, Name, ContactId FROM USER WHERE isactive=TRUE AND ContactId In:conlist]){
        LeadList = [select id,Name,CreatedDate,Company,OwnerId,Owner.Name,LeadSource,MAU__c,Estimated_Opportunity_Deal__c,recordType.Name,CRM_User__r.Name,CRM_User__r.Id,CRM_User__c, Status, Account__c,LastName,,Account__r.OwnerId
                    from Lead 
                    where    CRM_User__c !=null And Account__c=: acc.Id AND LeadSource='Partner' AND recordType.Name = 'Partner Lead Registration' ];

Vf page

<apex:page standardController="Account" extensions="PartnerLeadController" lightningStylesheets="true" sidebar="false"  >

    <apex:form >

        <apex:pageBlock rendered="true" >
            <apex:outputPanel layout="block" styleClass="container">
            <apex:pageBlockTable value="{!LeadList}" var="ld" width="100" >
            <apex:column >
                <apex:outputLink value="/{!ld.Owner}" target="_top">{!ld.Owner.Name}</apex:outputLink>
                <apex:facet name="header">Owner Name</apex:facet>
                 <apex:column ><apex:outputField value="{!ld.Name}" />
                <apex:facet name="header">Lead Name</apex:facet>
            <apex:column ><apex:outputField value="{!ld.Status}" />
                <apex:facet name="header">Status</apex:facet>
                <apex:column ><apex:outputField value="{!ld.Company}" />
                <apex:facet name="header">Company</apex:facet>
                 <apex:column ><apex:outputField value="{!ld.MAU__c}" />
                <apex:facet name="header">MAU</apex:facet>
                <apex:column ><apex:outputField value="{!ld.Estimated_Opportunity_Deal__c}" />
                <apex:facet name="header">Estimated Opportunity Deal</apex:facet>
            <apex:column ><apex:outputField value="{!ld.CreatedDate}" />
                <apex:facet name="header">CreatedDate</apex:facet>

Test class

public class PartnerLeadControllerTestClass {
    static testMethod void leadscontroller()
        Account myaccount = new Account (name='Test');
        insert myaccount;
        PageReference pageRef = Page.PartnerleadList;
        pageRef.getparameters().put('recordId', myaccount.Id);  
        Apexpages.StandardController sc = new Apexpages.StandardController(myaccount);
        PartnerLeadController partlead = new PartnerLeadController(sc);   


I understand your urgency (to a point).  However, I do not understand why you posted a new third version of this same question, when you never answered the last questions I asked you (after I helped you get it from 0% to 90%) in your first long post where I was helping you.

I do want you to get this working, and I do not care if I am the one who helps you; however, you have to help yourself some, too.

The questions I asked you in your first post were not unimportant - they were questions to get you to look closely at your code IN AN EFFORT TO HOPEFULLY HELP YOU GET THAT LAST BIT OF CODE COVERED.

Instead of asking everyone to essentially do your work for you, if you would have spent more time
  1. walking through your code closely,
  2. adding System.debug() statements throughout to help you walk through it,
  3. reading through the Apex Developer Guide (,
  4. going through the Trailhead Apex Testing ( module,
  5. reading through many good blogs and other internet web pages and posts on Apex and testing, and
  6. answering the questions asked by those who are trying to help you,
then you probably would have it at 100% right now.  And you would be in better position for next time.