Quality and maintenance · Question 10 of 12
A unit test should check a price calculation with several inputs. How do you provide the data in PHPUnit 13?
1 answer is correct. Medium
Show answer
Answer
- B With the attribute #[DataProvider('priceProvider')] on the test and a public static function priceProvider() that returns the data sets
Explanation
Since PHPUnit 12, PHPUnit only reads attributes, and annotations in the DocBlock are ignored. The provider must be public and static, each data set is run as a separate test, and named keys appear in the output. A loop in one test stops at the first failure and does not show which other inputs fail as well.