https://sebastiandedeyne.com/beware-of-phpunit-data-providers-with-heavy-setup-methods/ https://sebastiandedeyne.com/tags/php/ https://sebastiandedeyne.com/tags/phpunit/ https://sebastiandedeyne.com/tags/testing/Data providers can be a perfect fit to assert a lot of expectations without writing a full test for each. For an in-depth introduction to data providers, I recommend https://tighten.co/blog/tidying-up-your-phpunit-tests-with-data-providers/ on the Tighten blog. { /** @dataProvider values */ public function it_adds_values(int $a, int $b, int $result): void
If you don’t, data providers make your tests slower than they need to be.
class MyTest extends TestCase public function setUp(): void parent::setUp(); // Do some heavy lifting…