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
sumit dsumit d 

test class of controller in lightning

Hi All,
How to write test class for this controller class:-

public with sharing class DescribeHelper {
    public static List<SObjectFieldWrapper> getSortedFieldSetFields(String sObjectName, String fieldSetName) {
        List<SObjectFieldWrapper> objFields = new List<SObjectFieldWrapper>();
        //describe the provided sObject
        Schema.DescribeSObjectResult res = Schema.getGlobalDescribe().get(sObjectName).getDescribe();
        Map<String, Schema.FieldSet> fieldSetMap = res.fieldSets.getMap();
        Schema.FieldSet fs = fieldSetMap.get(fieldSetName);
        for(Schema.FieldSetMember fsm : fs.getFields()) {
            SObjectFieldWrapper sfw = new SObjectFieldWrapper();
            sfw.fieldName = fsm.getFieldPath();
            sfw.fieldType = fsm.getType().name();
            sfw.fieldLabel = fsm.getLabel();
            sfw.required = fsm.getRequired() || fsm.getDbRequired();
        return objFields;

    public class SObjectFieldWrapper implements Comparable {
        public String fieldName {get; public set;}
        public String fieldLabel {get; public set;}
        public String fieldType {get; public set;}
        public Boolean required {get; public set;}
        public Integer compareTo(Object withObj) {
            SObjectFieldWrapper compareTo = (SObjectFieldWrapper) withObj;
            return fieldLabel.compareTo(compareTo.fieldLabel);
Can anyone help me with test class of it?
public class DescribeHelperTest {
    static void testMethodOne() {	
        // replace first and second param with your object and fieldset api name  
        List<DescribeHelper.SObjectFieldWrapper> lstResult = DescribeHelper.getSortedFieldSetFields('Account', 'MyFieldSet');

Hope this will help