Implement a data provider
lobodol opened this issue · 3 comments
lobodol commented
As a PHP developper I'm used to use PHPUnit which provides a lot of useful annotations.
One of them that I use very frequently is @dataProvider.
It would be nice to have the same in ArduinoUnit.
wmacevoy commented
Sorry annotations are not a feature of C++, the language Arduino's are programmed in. You could provide the loop yourself with something like:
void pTest(int x, int y) {
assertEqual(x,y);
}
test(pTest) {
static struct { int x; int y; } data [] = { {1,1}, {1,3}, {2,1} };
for (auto p : data) {
pTest(p.x,p.y);
}
}
wmacevoy commented
test(pTest) would call all the pTest's, and would be a fail if any of them failed. If you want to fail early, you can add a if (currentTestFailed()) return;
to the inside of the for-loop.
lobodol commented
Arf you're right, I forgot this point.
No matter, I'll simply use basic loops for this feature.