You need to sign in to do that
Don't have an account?
Jennifer BERNARD
SOQL request from test does not have the same result than request sent from debug
Hello everyone,
When I set mock up data in a test class, a trigger is fired and this request is sent in its process :
When I set mock up data in a test class, a trigger is fired and this request is sent in its process :
SOQL_EXECUTE_BEGIN [15]|Aggregations:0|SELECT id FROM Pricebook2 WHERE Name LIKE '%Standard%' SOQL_EXECUTE_END [15]|Rows:0But when I send this request in the Debug window I get this:
SOQL_EXECUTE_BEGIN [1]|Aggregations:0|SELECT id FROM Pricebook2 WHERE Name LIKE '%Standard%' SOQL_EXECUTE_END [1]|Rows:1Is it a profile issue ? Or a bug ? Or something else ? The trigger process failed because it cannot find any records from Pricebook2 table.
Test classes by default cannot access real data. It can access only the test data created within the test class.
Please refer below for details:
https://salesforce.stackexchange.com/questions/102455/query-works-in-anonymous-window-but-fails-in-test-class
If it helps please mark it as best answer.
Thanks!