4 ms·
This is a common practice and more often than not the data is reused, so it is provided by a "data provider", a method living in the test code, which returns a
by nerdy 12y ago
This is a common practice and more often than not the data is reused, so it is provided by a "data provider", a method living in the test code, which returns a structure with inputs and expected results.
For example, in PHPUnit: https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers https://phpunit.de/manual/current/en/writing-tests-for-phpun...
It would actually be even more elegant if the data where extracted out of the test methods in my opinion. Though it would effectively double the number of methods, it cleans things up significantly within the test methods, provides an outlet for extension and the only expense is the addition of declaration & closing lines.