SalesforceTrailhead
  • Today
© 2026 Salesforce, Inc. All rights reserved. Privacy Terms of Use Trust Accessibility Cookie Preferences
Apex Testing

Test Apex Triggers

+500 Points~45 minsHands-On Challenge
Apex TestingTest Apex Triggers

Org:Mindful Goat Playground

Topics

  • Concepts
  • Hands-On Challenge

Looking for help?

Explore Help ResourcesShare Your Feedback
Learning Objectives

After completing this unit, you'll be able to:

  • Write a test for a trigger.
  • Run tests in the Developer Console.

Concepts

Test triggers by performing the DML that fires them inside Test.startTest() and Test.stopTest(), then assert the results.

Hands-On Challenge

  1. Create the RestrictContactByName trigger from the resources.
  2. Write TestRestrictContactByName that inserts a contact with last name INVALIDNAME and asserts the error.
Check ChallengeDemo check
Previous UnitGet Started with Apex Unit TestsNext Unit Create Test Data for Apex Tests