• 1Installation
  • 2Preliminary Knowledge
  • 3Create Triggers
  • 4Trigger Handler
  • 5Bulk Object
  • 6Find Specific Objects
  • 7Data Sharing
  • 8Catch All Events
  • 9Trigger Controller
  • 10Normal Trigger Event Handler
  • 11Trigger Context
  • 12Unit Test
  • 13Take Only Trigger Execution

Trap.apex

  • Docs
  • Tutorials
Getting started with Trap.apex

Unit Test

Unit testing with Trap.apex is easy. Here is how you do it in the unit test.

@isTest
private static void contextTest() {
    // test code

    Trap.getInstance().start(Trap.Event.BeforeInsert, null, new List{ new Case() });

    // test code
}

Pass the trigger event, old list and new list into the Trap.start or TriggerHandler.run, and the same code will be executed completely from the data you passed in, not from Salesforce trigger context.

Done