Salesforce Developer Tutorial: How to use DML Mocking in your Apex Tests

In this episode we go over how to setup your codebase to allow you to leverage DML mocking in your apex testing. Leveraging mocking in your tests will allow you to run your tests considerably faster as well as test your code at a much finer level. Schedule Salesforce consulting time with me here: https://calendly.com/codingwiththefor... Please consider donating to help continue to improve the content produced for Coding With The Force: https://www.paypal.com/donate?busines... Get Coding With The Force Merch Here: https://my-store-d20559.creator-sprin... GitHub Repo: https://github.com/Coding-With-The-Fo... UniversalMock GitHub: https://github.com/surajp/universalmock The MockIdBuilder and MockSObjectBuilder classes were originally created by Caleb Weaver. An extremely talented developer I was very lucky to work with. His code is in my GitHub repo for this video. Follow all of our social media here: Patreon:   / codingwiththeforce   Github: https://github.com/Coding-With-The-Force Facebook:   / codingwiththeforce   Twitter:   / coding_force   Instagram:   / codingwiththeforce   Salesforce development books I recommend: Advanced Apex Programming: https://amzn.to/3lXi8to Salesforce Lightning Platform Enterprise Architecture: https://amzn.to/2R0D4BQ Mastering Salesforce DevOps: https://amzn.to/3lTtTRN Apex Design Patterns Book: https://amzn.to/3DwqljP Good Non-SF Specific Development Books: Clean Code: https://amzn.to/35PuMDU Clean Architecture: https://amzn.to/35FYo6A Design Patterns: Elements of Reusable Object-Oriented Software Book: https://amzn.to/3LhvHBd ------------------------------------------------------------------------------------------------------------------------- Table of Contents: 0:00 - Intro 0:24 - Why use mocking at all 5:44 - What is Mocking 6:54 - How to setup your apex classes to allow mocking 10:36 - How to Setup Mocking in your test classes 23:35 - Understanding how to construct your codebase to use DML Mocking 30:37 - Outro DISCLAIMER: The views and ideas expressed on this YouTube channel and blog are based on past development experiences and may not always work for your particular scenarios. The advice in these videos may also become outdated as technology advances. They should be used as examples for educational purposes only. Using any shown solutions in your own org is not advisable since they are example scenarios. #salesforce #salesforcedeveloper #salesforceadmin

Salesforce Developer Tutorial: How and When to use Interfaces In Apex
▶︎

Salesforce Developer Tutorial: How and When to use Interfaces In Apex

Salesforce Developer Tutorial - The Complete Guide to Apex Tests in 2024
▶︎

Salesforce Developer Tutorial - The Complete Guide to Apex Tests in 2024

Zig 2026: No-AI Policy, $670K Foundation, Left GitHub & Why Zig Isn’t 1.0 - Andrew Kelley Explains
▶︎

Zig 2026: No-AI Policy, $670K Foundation, Left GitHub & Why Zig Isn’t 1.0 - Andrew Kelley Explains

Salesforce Development Tutorial - A Complete Guide To Asynchronous Apex in Salesforce
▶︎

Salesforce Development Tutorial - A Complete Guide To Asynchronous Apex in Salesforce

Kubernetes Zero to Hero: The Complete Beginner’s Guide (2025 Edition)
▶︎

Kubernetes Zero to Hero: The Complete Beginner’s Guide (2025 Edition)

Salesforce Developer LWC Tutorial - The Beginner's Guide to Lightning Web Components in 2026
▶︎

Salesforce Developer LWC Tutorial - The Beginner's Guide to Lightning Web Components in 2026

Basic of SOQL and SOSL in Salesforce | SOQL Crash Course | DAY 4 Part 1
▶︎

Basic of SOQL and SOSL in Salesforce | SOQL Crash Course | DAY 4 Part 1

Salesforce Developer Tutorial (LWC) - The Complete Guide to LWC Lifecycle Hooks
▶︎

Salesforce Developer Tutorial (LWC) - The Complete Guide to LWC Lifecycle Hooks

Full App Building Course with Cursor (3+ Hours)
▶︎

Full App Building Course with Cursor (3+ Hours)

Salesforce Developer Tutorial: How to use Wrapper Classes in Apex to Simplify your Integrations
▶︎

Salesforce Developer Tutorial: How to use Wrapper Classes in Apex to Simplify your Integrations

ASP.NET Core Full Course For Beginners (.NET 10)
▶︎

ASP.NET Core Full Course For Beginners (.NET 10)

Salesforce Developer Tutorial - How and Why to use Scratch Orgs for Development
▶︎

Salesforce Developer Tutorial - How and Why to use Scratch Orgs for Development

Allen Bradley PLC Programming Sequencer Tutorial. Sequence Control
▶︎

Allen Bradley PLC Programming Sequencer Tutorial. Sequence Control

Salesforce Developer Tutorial - Apex and LWC Debugging Techniques
▶︎

Salesforce Developer Tutorial - Apex and LWC Debugging Techniques

Salesforce SoC and Apex Common Tutorial Series: Ep 4 - The fflib Application Class
▶︎

Salesforce SoC and Apex Common Tutorial Series: Ep 4 - The fflib Application Class

Developer Tools & Debugging Tools | DAY 3
▶︎

Developer Tools & Debugging Tools | DAY 3

Pointers in C / C++ [Full Course]
▶︎

Pointers in C / C++ [Full Course]

Complete Terraform Course - From BEGINNER to PRO! (Learn Infrastructure as Code)
▶︎

Complete Terraform Course - From BEGINNER to PRO! (Learn Infrastructure as Code)

Salesforce SoC and Apex Common Tutorial Series: Ep 17 - Implementing Unit Testing with Apex Mocks
▶︎

Salesforce SoC and Apex Common Tutorial Series: Ep 17 - Implementing Unit Testing with Apex Mocks

Please Learn How To Write Tests in Python… • Pytest Tutorial
▶︎

Please Learn How To Write Tests in Python… • Pytest Tutorial