We have a large suite of tests with lots of test case functions. Due to running on many platforms/configurations, we now need to add logic to skip inapplicable tests. The "direct" way of doing so would involve adding this to the top of every single test method:
if (!CheckApplicable(/* Input some enum value of test type/platform, etc */))
{
SkipTest();
return;
}
I don't really want to paste that everywhere. I would prefer a data-driven look such as attributes if possible. But can an attribute somehow tell it to run code at function start? Any other tricks/techniques, maybe involving reflection, that are worth looking into, that wouldn't be more trouble than they're worth? If not, is there at least some clean way to collapse that type of logic into a single line, while still causing the early return?
Note that we need to exit with a return, not by throwing. Also, we cannot switch test frameworks (we are using TAEF).
Edit: Also note that the outcome of CheckApplicable currently is not known until it is checked at runtime at some point. It is not knowable statically and it cannot depend on the command line due to the peculiarities of a large infrastructure. We could run it once super early though, and somehow reconfigure the test pass then, or just run it before every test case.