junit4
junit4 copied to clipboard
Parameterized: added new @StaticParameter annotation
The new annotation allows to inject parameterized values in static test members.
This is useful when one has to run a parameterized test case against parametric expensive resources.
Can you please provide an example where this is useful?
I made this to do an integration test of a mail processor. The processors uses a MessageBatch abstraction which insists on different mail stores (i.e. protocols). As you can imagine, the interface is the same, but the behavior is not. I set up only one parametric test case, where different MessageBatch implementations get tested. Each of them, though, requires to connect to a different store, which is a slow task to do at each test method.
An alternative (which I implemented) without static parameter injection is to use a @ClassRule whith static fixtures, from which pull needed mail folder and such. IMHO, this solution is less straightforward than a static injection.
BTW, I can understand this is a bit a corner case.
I am not sure I completely understand, but it sounds like your use case is a bit of a stretch for Parameterized. You aren't testing one thing with multiple values, you are testing multiple implementations.
Can you provide an example of what your test looks like with static injection and what it looks like with @ClassRule?
I think that something like @BeforeParameterRun in #45 would be a solution to your problem, too. Am I right?