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
Abhilash DaslalAbhilash Daslal 

Test class for a dynamic query

Hi Guys,
I want to write a test class for a controller class having dynamic query.please give examples....

Eg-
query = 'SELECT id' + ',' + fields +'FROM'+ objectName + 'WHERE' + queyCondition '=accId';
sObjectList = Database.query(query); 

Thanks,
Abhilash
Gaurish Gopal GoelGaurish Gopal Goel
Hi Abhilash, Please post the complete code.

By the way you just need to create your test data and call your controller method. There is nothing special required for this dynamic query. If this answer solves your problem then mark it as the solution to help others. Thanks.