Unit Tests in Magento 2
fast and effective without bootstrap
Unit tests in Magento 2 feel heavy to many teams because they are built too close to the framework or too far away from real value. Good tests, by contrast, are small, fast and placed exactly where custom logic actually creates risk.
Table of Contents
- 1. What makes a good Magento 2 unit test
- 2. Why unit tests without bootstrap are faster
- 3. Cutting your own logic so it is testable
- 4. Mocking with restraint instead of mocking as an end in itself
- 5. Where unit tests in Magento really pay off
- 6. Typical mistakes
- 7. Unit tests vs. integration tests
- 8. Magento 2 support
- 9. Summary
- 10. FAQ
1. What makes a good Magento 2 unit test
A good Unit Tests Magento 2 approach checks your own logic in isolation and quickly. That sounds trivial, but in practice it is often missed. Either pure getters, framework configuration or trivial delegations get tested,