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
Advanced Apex Testing

Test Security and Async Code

+1,000 Points~1 hrHands-On Challenge
Advanced Apex TestingTest Security and Async Code

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:

  • Test code as different users.
  • Test asynchronous code deterministically.

Concepts

Use System.runAs to prove sharing and permissions behave for each persona, and wrap async work in Test.startTest() / Test.stopTest() so it finishes before you assert.

Hands-On Challenge

  1. Write a test that runs OpportunityClose as a user without edit access and asserts it fails.
  2. Write a test that enqueues FollowUpJob and asserts its task after Test.stopTest().
Check ChallengeDemo check
Previous unitMock and Stub ObjectsBack to badge Advanced Apex Testing