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
HoysalaHoysala 

Please can someone send the min 85% of code coverage for the below apex class... please help. Thanks...

public with sharing class AccController
{
    public list <account> acc {get;set;} 
    public string searchstring {get;set;} 
    Public Boolean ShowCreateBlock{get;set;}
    public Boolean ShowBlock{get;set;}
    Public Boolean DisplaySearchResults{get;set;}
    public Account account{get;set;}
    Public Account NewAccountRecord{get;set;}
    
    public AccController()
    {
        ShowCreateBlock = false;
        ShowBlock=True;
        DisplaySearchResults = false;
        NewAccountRecord= New Account(Name='Test');
        
    }
    
    public String getAccount()
    {
        return null;
    }
    
    
    public String options { get; set; }
    
    public PageReference executeSearch() {
        return null;
    }
    public list<account> showList = new list<account>([select Name, Email__c,Phone from Account]);
    Public list<account> getshowList()
    {
        
        return showList;
    }
    
    
    public PageReference create()
    {
        return null;
    }
    
    public pagereference search()
    { 
        string searchquery='select name,id from account where name like \'%'+searchstring+'%\' Limit 20'; 
        acc= Database.query(searchquery);
        DisplaySearchResults =true;
        if(acc.size()==0)
        {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'account not found'));
            ShowCreateBlock = true; 
            ShowBlock=False;
        }
        return null;
    }
    public void clear()
    { 
        acc.clear(); 
    } 
    Public pagereference saveRecord(){
        insert NewAccountRecord;
        pagereference  pageRef = new pagereference('/'+NewAccountRecord.Id);
        return pageRef ;
    }
}

 
Raj VakatiRaj Vakati


Check the other post .. your test class might be failing .. if you can give me the reason we can able to rewrite ..


code i shared i am getting 100 %  coverage