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.