+ 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....

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

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.