You need to sign in to do that
Don't have an account?
Soul Ages
Can't search user unique field in tests
After having most test failed suddenly for no apparent reason, we found that the culprit was that a field we were using to search for a special user was changed to be unique.
User[] users = [select id from User where Unique_Field___c = :'Special' limit 1]; System.assert(users.size()>0, 'Missing Special user configuration.');
If I run the code in a test method, I get 'Missing Special user configuration.' assert exception. If I run it in a developer console, it runs without the assert triggering.
Any ideas why is this? Is it a bug or feature? Is it documented anywhere?
Hi
Have you put the "seeAllData" condition in the Test Class?
Like this: @isTest(seeAllData=true)
No, but according to this users are still visible in tests. And if I remove the unique property from the field, the test works.