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 

Urgent Please help test class is failing

I have written the below test class to add list of partner leads with record type as Partner Lead registartion on account page. Can you help me with the code
@isTest
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);  
        Test.setCurrentPage(pageRef);
        
        Apexpages.StandardController sc = new Apexpages.StandardController(myaccount);
        PartnerLeadController partlead = new PartnerLeadController(sc);   
        partlead.getlead();
        partlead.initlead();
    }
   
}

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]){
            UserContactId.add(u.Id);
        }
        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.id,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:column ><apex:outputField value="{!ld.Name}" />
                <apex:facet name="header">Lead Name</apex:facet>
            </apex:column>
            <apex:column ><apex:outputField value="{!ld.Status}" />
                <apex:facet name="header">Status</apex:facet>
            </apex:column> 
                <apex:column ><apex:outputField value="{!ld.Company}" />
                <apex:facet name="header">Company</apex:facet>
            </apex:column> 
                 <apex:column ><apex:outputField value="{!ld.MAU__c}" />
                <apex:facet name="header">MAU</apex:facet>
            </apex:column> 
                <apex:column ><apex:outputField value="{!ld.Estimated_Opportunity_Deal__c}" />
                <apex:facet name="header">Estimated Opportunity Deal</apex:facet>
            </apex:column> 
                
            <apex:column ><apex:outputField value="{!ld.CreatedDate}" />
                <apex:facet name="header">CreatedDate</apex:facet>
         
            </apex:column> 
            </apex:pageBlockTable>
                </apex:outputPanel>
        </apex:pageBlock>  
      
    </apex:form>
</apex:page>

User-added image
SUCHARITA MONDALSUCHARITA MONDAL
Hi Shruthi,
There is no method as 'getLead() and initLead()' in your Controller class (PartnerLeadController) that you are trying to call from Test class.  Create those method in Controlled class and it'll work/

Thanks,
Sucharita
Shruthi NarsiShruthi Narsi
Can you wrote the test class for me..im not aware of it
MoonpieMoonpie
Shruthi,

May I ask why you posted this question again, when I am actively helping you in another (very long) post?
Lottery Sambad 18Lottery Sambad 18
Thanks for this nice post Sattaking (https://sattakingfirst.ind.in/) is a big online money givingn game