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];

1 Answer 1


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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .