Since version 10, PHPUnit has set a clear direction: the old @annotation docblocks are being replaced step by step with real PHP 8 attributes such as #[Test], #[DataProvider], and #[Group]. Anyone still relying on annotations is giving up type safety, IDE support, and cleaner error diagnostics. This article explains why the switch is worth it and how to migrate an existing test suite step by step.
Anyone who resolves GraphQL filters in Magento naively through raw SQL or direct model queries builds up technical debt. The correct path runs through the SearchCriteriaBuilder, with type-safe arguments in the schema, clean delegation in the resolver and testable filter logic in the service contract.
Magento integration tests built on XML fixtures are fragile, hard to maintain and barely readable. PHP based fixtures, the DataBuilder pattern and consistent use of the ObjectManager produce test data that is readable, reliable and easy to adjust, without fixture files that break after every schema update.
From the schema definition through the ResolverInterface to DI configuration, error handling and integration tests: the complete path to a production-ready Magento GraphQL resolver, no shortcuts.
Multiple plugins on the same method silently depend on the sortOrder in di.xml. A test that documents the actual execution order prevents a new plugin from silently tipping over an existing order and, with it, the behavior.
Anyone who blindly treats every collaborator as a Mock loses the semantic expressiveness of their tests. Stub, Fake, Spy, Mock and Dummy have clearly defined roles, and whoever confuses these roles ends up writing tests that hide bugs instead of surfacing them.
Hand-written test data like 'Test Name' or 'test@test.com' hides real bugs because it never reflects the diversity of real input. The Faker library generates realistic names, addresses, and prices while staying fully reproducible with fixed seeds.
Legacy code is code without tests, and it cannot be changed safely without tests. The way out of this dilemma begins with characterization tests: tests that document the actual behavior, not the desired one. Introduce seams, break static dependencies and extract classes step by step, without changing a single line of production logic before the first test is green.
@codeCoverageIgnore excludes lines of code from the coverage calculation, making it a legitimate tool for cases where real testability is neither meaningful nor possible, such as trivial getters or unreachable defensive code. But when the annotation gets spread generously over code that is hard to test but genuinely worth testing, an honest measurement tool turns into an inflated number that gives the team a false sense of safety.
Anyone who only runs PHPUnit from the command line is giving up most of PhpStorm's productivity. Run Configurations, coverage reports right in the editor, test filters down to a single method, and the Docker remote interpreter turn PhpStorm into a complete testing environment, without ever leaving the terminal behind for good reason.