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
Akhil Katkam 5Akhil Katkam 5 

test class for this method

Hi Developer Community , 

please help me with this , how to write test class for this
global ObjectFieldPickList(VisualEditor.DesignTimePageContext context) {
        this.rows = getRows(context.pageType, context.entityName);
    }

Thanks in Advance
ShivankurShivankur (Salesforce Developers) 
Hi Akhil,

Please check with below type of test class:
@isTest(seeAllData=false)
private with sharing class ObjectFieldPicklist_Test {
  @isTest
  static void testObjectFieldValue() {
    VisualEditor.DesignTimePageContext context = new VisualEditor.DesignTimePageContext();
    context.entityName =EntityName;
    OriginalApexClass inst = new OriginalApexClass(context);
    Test.startTest();
    VisualEditor.Datarow defaultValue = inst.getRows();
    Test.stopTest();
  }
}
PS: This is just example code and may or may not work for your particular use case, please try to modify according to usage.

Hope above information helps, Please mark as Best Answer so that it can help others in the future.

Thanks.
mukesh guptamukesh gupta
Hi Akhil,

Please use below code:-
 
@isTest
private class MyTestClass {
    @isTest static void myTest() {
       VisualEditor.DesignTimePageContext vdtObj = VisualEditor.DesignTimePageContext();
        vdtObj.pageType = 'HomePage'; /// you can change pageType like Web/Home/App according to you
        vdtObj.entityName = 'Account'; /// you can change object name according to you
        
        insert vdtObj;
        yourapexCls.ObjectFieldPickList(vdtObj);
    }
}

if you need any assistanse, Please let me know!!


Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh