Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterized: added new @StaticParameter annotation #1381

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

meden
Copy link

@meden meden commented Nov 1, 2016

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.

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.
@marcphilipp
Copy link
Member

Can you please provide an example where this is useful?

@meden
Copy link
Author

meden commented Nov 1, 2016

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.

@kcooney
Copy link
Member

kcooney commented Nov 1, 2016

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?

@stefanbirkner
Copy link
Contributor

stefanbirkner commented Nov 10, 2016

I think that something like @BeforeParameterRun in #45 would be a solution to your problem, too. Am I right?

@marcphilipp marcphilipp changed the base branch from master to main June 21, 2020 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants