-
-
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
Add mechanism for registering dynamic tests #58
Comments
@mmerdes and I are starting on some experiments with it. See branch https://github.com/junit-team/junit5/tree/issue58-dynamic-tests |
Awesome! Just skimmed the work in the branch, and... it's great that you guys are making progress here. Looking forward to the result... Good Luck! |
I don't think we'll go much further with branch ( Here's a summary of what we learned so far:
Our suggestion is that you guys look at the programming model and the |
Had a quick look. I like it for one big (at least for me) reason: It seems to easily allow writing Tests as closures. With a simple class using these dynamic tests, it should be able write tests like:
|
This looks great. I played around a bit. @Dynamic
public Stream<DynamicTest> dynamicTest() {
return DynamicTest.streamFrom(parameters(), param -> "test-" + param, this::testWithSingleParam);
}
public Iterator<String> parameters() {
return Arrays.asList("foo", "bar", "baz").iterator();
}
public void testWithSingleParam(String param) {
// parameterized test here...
} this way, multiple parameter generation methods can be in a single class. |
Would be cool to have the opportunity to create dynamic tests by an extension. I thought about it and would like to allow an extension to replace a
This would be very useful to migrate libraries like junit-dataprovider and make them an extension from the former JUnit4 Runner. |
@aburmeis, thanks for bringing this up. I agree: JUnit 5 will likely need to provide support for two types of dynamic tests:
The latter would allow for a certain category of dynamic tests that are executed analogous to methods annotated with |
- HierarchicalTestExecutor only executes children from containers - Unique IDs for dynamic tests are created using index - Add tests for discovery of dynamic test by method selector (#58)
Pull request for current work-in-progress submitted: #278. |
Further Resources
The text was updated successfully, but these errors were encountered: