Cert++
Close

Unit testing cart calculators and integration classes

Key Takeaway

Test cart extensions with Salesforce's test-only helpers: build the cart and request yourself, set buyer actions on BuyerActionsMock, and fake default logic with a CartCalculateExecutorMock subclass.

Custom cart calculators and orchestrators extend CartExtension base classes, and Salesforce normally builds the cart and request objects they receive. A unit test has to build those objects itself, so Salesforce provides test-only helpers. These helpers build a cart, fake buyer actions and change details, and swap the default calculator logic for a mock.

Test and coverage requirements

Every extension provider class needs Apex tests, including a custom calculator or orchestrator. Apex classes and triggers need at least 75% code coverage. Salesforce recommends writing the tests before the code, so the requirements are clear and you have a reliable way to check the code.

Salesforce Accredited B2B Commerce Developer Professional Study Guide

Checklist progress

0/124Learned

Code implementations against the 4 crucial reference implementations used in checkout and payment interfaces with in-depth knowledge of all supported actions

0/23

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other Salesforce Accredited B2B Commerce Developer Professional studiers. 757 members and growing.