Getting Started

  • What is Trailhead
  • myTrailhead
  • Trailblazer Community
  • Career Growth

Learn

  • Trails
  • Trailmixes
  • Modules
  • Projects

Credentials

  • Superbadges
  • Certifications
  • Maintain Certifications

Salesforce

  • Salesforce.com
  • AppExchange
  • Developers
  • Help Portal
© 2026 Salesforce, Inc. All rights reserved. Privacy Terms of Use Trust Accessibility Cookie Preferences
SalesforceTrailhead
  • Today
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