-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Support @ParameterizedTest in conjunction with @TestFactory #1192
Comments
Why don't you just extract the logic from your You could put that in a common utility and use the utility (e.g., static factory method) both from your provider as well as in test factories. |
FWIW, it is not feasible for JUnit Jupiter to treat a single method as two containers simultaneously: it just doesn't make sense. Note that a |
Assigned to 5.1 backlog for team discussion. |
Is this related to the API Guardian project created by the JUnit 5 team? |
This is my junit5 implementation of guard assertions as described here: It takes all public methods of a class and checks if null arguments are safely handled. So it generates for each parameter of each method a dynamic test. Now I want combine this to get these tests generated for each class in the package. So I want nested Testcontainers like nested classes: Combining a TestFactory with ParametrizedTest was the most obvious for me. |
We actually already have support for nested dynamic containers! 😉 In the Dynamic Test Examples section of the User Guide you'll find a test method named I think that will cover your needs, but please reply here to let us know in any case. Cheers! Sam |
Here, at ConsoleDetailsTests is another example of dynamic container usage which produces a tree like: |
When it is supported by code to have nested dynamic containers it should also be possible by annotation. |
I'm closing this issue as "declined". |
Re @sbrannen "Why don't you just extract the logic from your |
Overview
I started to write some dynamic tests, and now it would be handy to reuse some
@ParameterizedTest
functionality I already implemented.Take a look at this example:
This should generate some dynamic tests for each class found in the package, but sadly the
@ParameterizedTest
annotation is not supported with a@TestFactory
method.Kind regards,
Michael
Related Issues
The text was updated successfully, but these errors were encountered: