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

@MethodSource equivalent with support for simple EL #792

Open
crizzis opened this issue Nov 25, 2023 · 1 comment
Open

@MethodSource equivalent with support for simple EL #792

crizzis opened this issue Nov 25, 2023 · 1 comment

Comments

@crizzis
Copy link

crizzis commented Nov 25, 2023

I have an idea of a potential new feature and was wondering if you think it is worth the effort.

When using parameterized tests, I tend to shy away from using @MethodSource, bc in heavily parameterized suites, it would force you to add a ridiculous amount of extra methods. To me, the main culprit seems to be the requirement for each such method to be parameterless, thus completely resistant to any generalization.

I was wondering if it wouldn't make more sense to have sth like a @ExpressionSource where we could use some sort of an existing open-source EL engine.

In its simplest form, it would allow for passing primitive parameters to methods (imagine e.g. a security test where you could use expressions like @ExpressionSource("allRolesExceptFor('ADMIN')")).

In an advanced scenario, it could also allow access to: injected constructor params, test instance variables, test context (not sure how this would fit with the test lifecycle, though - it would probably require a little more investigation).

@Michael1993
Copy link
Member

We have discussed supporting some kind of EL related to some issues - the main takeaway was that the costs seem to outweigh the benefits. This does not mean that we would outright refuse to support a good solution. Your idea could be solved with a straightforward @EnumSource - you can even have that enum in a separate file, so it does not clutter your tests.

I am uncertain about the last part of the issue, could you provide a bit more context?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants