Running specific PHPUnit data provider data set

Matt Glaman
1 min readMar 7, 2023

I’m a huge fan of using data sets for PHPUnit test cases to cover as many permutations as possible with given inputs. The only problem is when you want to execute a specific data set for the test. I’m not much of a PHPUnit command line guru since I run tests individually in PhpStorm. My workflow is generally: run the test method and use re-run failed tests to execute those specific data sets. But! This has changed with recent versions of PhpStorm.

Now there is the ability to run an individual data set for a test. You can now click the gutter icon to run or debug a specific data set for a PHPUnit test like running individual tests.

Data provider for a test with "run" arrows in the IDE gutter

I don’t know what version released this feature. It is not called out in the release notes but I think it may have been with 2022.2 when they released highlighting failed test assertions.

--

--

Matt Glaman
Matt Glaman

Written by Matt Glaman

PHP software engineer, open source contributor, and speaker

No responses yet