Skip to content

The MockDml.Savepoint Class

Jason Siders edited this page Jul 4, 2025 · 5 revisions

This class decorates a System.Savepoint object, and keeps track of its usage throughout a transaction. Refer to this object's properties when you need to assert if a savepoint was rolled back or released.

You can access MockDml.Savepoints via the MockDml.SavepointHistory class, which is acccessible via the MockDml.SAVEPOINTS static property. Read more about the MockDml.SavepointHistory class here.

Example:

DatabaseLayer.useMocks();
System.Savepoint savepoint = DatabaseLayer.Dml.setSavepoint();

Test.startTest();
DatabaseLayer.Dml.rollback(savepoint);
Test.stopTest();

MockDml.Savepoint sp = MockDml.SAVEPOINTS.get(0);
Assert.areEqual(true, sp?.wasRolledBack);
Assert.areEqual(false, sp?.wasReleased);

Properties

Property Name Data Type Details
index Integer (Read-only) The Savepoint's index, corresponding with the number of savepoints generated in the transaction, starting with 0.
name String (Read-only) The Savepoint's name, which is discoverable via the System.Savepoint's toString() value.
wasReleased Boolean (Read-only) Indicates whether DatabaseLayer.Dml.releaseSavepoint() was called for the current savepoint.
wasRolledBack Boolean (Read-only) Indicates whether DatabaseLayer.Dml.rollback() was called for the current savepoint.
Clone this wiki locally