3

I have a SOQL query that uses the FOR UPDATE statement. Actually, this query is in a selector class. Now I want to test my selector class, but how would I test that records returned by this query are actually locked?

This is a simplified version of my class:

public with sharing class AccountsSelector
{
  return [SELECT Id FROM Account FOR UPDATE];
}
6

There isn't a way to test/verify that records are indeed locked. That said, you do not need to write unit tests that verify system logic. You can assume that locking works correctly and that any bugs in record locking would be caught in salesforce.com's system unit tests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.