-
Notifications
You must be signed in to change notification settings - Fork 0
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);| 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. |
- Generating Test Records
- Dml
- Soql
- Cmdt
- Plugins
- DatabaseLayer
- Dml
- MockDml
- MockRecord
- Cmdt
- MockCmdt
- MockSoql
-
Soql
- Soql.AggregateResult
- Soql.Aggregation
- Soql.Binder
- Soql.Builder
- Soql.Condition
- Soql.ConditionalLogic
- Soql.Criteria
- Soql.Cursor
- Soql.Function
- Soql.InnerQuery
- Soql.InvalidParameterValueException
- Soql.LogicType
- Soql.NullOrder
- Soql.Operation
- Soql.Operator
- Soql.ParentField
- Soql.PreAndPostProcessor
- Soql.QueryLocator
- Soql.Request
- Soql.Scope
- Soql.Selectable
- Soql.SortDirection
- Soql.SortOrder
- Soql.Subquery
- Soql.TypeOf
- Soql.Usage
- Soql.WhenClause