Hacker News new | ask | show | jobs
by nerdy 4084 days 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-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.