+ Start a Discussion
Mandar Kulkarni 13Mandar Kulkarni 13 

Need help in writing a test class.

Please help in writting test class for below controller 
Controller : 
public with sharing class accountLst {

      public static Map<Id, String> recordtypemap {get;set;}
    public static List<String> fetchRecordTypeValues(){
        List<Schema.RecordTypeInfo> recordtypes = Account.SObjectType.getDescribe().getRecordTypeInfos();    
        recordtypemap = new Map<Id, String>();
        for(RecordTypeInfo rt : recordtypes){
            if(rt.getName() != 'Master')
            recordtypemap.put(rt.getRecordTypeId(), rt.getName());
        return recordtypemap.values();
    public static Id getRecTypeId(String recordTypeLabel){
        Id recid = Schema.SObjectType.Account.getRecordTypeInfosByName().get(recordTypeLabel).getRecordTypeId();        
        return recid;
    public static List<account> findByName(String cName){
        String nm='%'+cName+'%';
        return [SELECT id, Name, Phone, Post_Code__c, Categories_del__c FROM Account where Name LIKE :nm LIMIT 20];
public class accountLstTest {
    public static void accountLstTestmethod(){

Note: Replace "recordTypeLabel" with the label of record type present in your org on Sobject 'Account'
other wise it will fail.