A Salesforce Apex library for generating test data with complex relationships and creating method stubs using BDD-style mocking.
Apex Test Kit is a Salesforce Apex library designed to simplify the creation of test data and method stubs for unit testing. It solves the problem of generating complex, related sObject hierarchies and provides a BDD-style mocking framework to replace dependencies in test scenarios. The library helps developers write more maintainable and efficient tests by reducing boilerplate code and improving test data management.
Salesforce developers and engineers who write Apex unit tests and need to generate realistic test data with relationships or mock external dependencies. It is particularly useful for teams building complex Salesforce applications with extensive testing requirements.
Developers choose Apex Test Kit because it offers a fluent, chainable API that dramatically reduces the code needed to create test data with relationships. Its built-in mocking framework follows BDD patterns, enforces strict mode by default to prevent test pollution, and provides performance benefits by generating mock data faster than database inserts.
A way to simplify your Salesforce data creation and method stubbing.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Enables creation of arbitrary many-to-one, one-to-many, and many-to-many relationships with a fluent API, as shown in the sales object graph example generating 200 accounts with nested contacts and opportunities.
Provides keywords like index(), repeat(), and arithmetic operations to generate field values automatically, reducing manual coding for test data setup.
Implements given-when-then patterns with strict mode enforcement, making test stubs cleaner and more maintainable, as demonstrated in the BDD example with ATK.mock().
Mock data generation is significantly faster than database inserts, with benchmarks showing up to 6.5x speed improvement in real time for 1000 accounts.
The chainable API with keywords like also(), junctionOf(), and depth management requires understanding of context and can be confusing for new users, increasing onboarding time.
Only supports Directed Acyclic Graphs, disallowing cyclic relationships that might be needed in complex Salesforce data models, which restricts some test scenarios.
As noted in the README, features like HttpCalloutMock support in BDD style are planned but not yet implemented, limiting its use for mocking external callouts.