-
-
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
Introduce mechanism for terminating Dynamic Tests early #431
Comments
With #838 in the works, it is easy to get and store the initial time instant when a "@testfactory"-annotated methods started. The user-supplied code then could calculate the difference to now and throw an (time out) exception in a " Or, a time-out value could be passed at the "@testfactory" annotaion level and the interpreted internally. |
Or the user may supply a predicate object that is asked before every dynamic test execution whether the execution loop should continue or not. |
The time-out use-case is already achievable via:
|
tl;dr #838 will solve this issue. |
Using a "required test" that throws an exception seems to be a hack to me. I definitely would not call that intuitive in terms of the programming model. Similarly, consider what the user's code would look like when implementing a custom IMHO, I believe we need a more elegant, first-class solution to the problem addressed by this issue -- one that works even if there is no such thing as a "required test". |
Supporting a user-defined timeout per test factory and/or a predicate that is provided a contextual object (containing information such as number of successful test, number of failed tests, number of aborted tests, number of skipped tests, duration of execution thus far, etc.) would be more intuitive and less burdensome on the end user. |
As far as I know the dynamic test API makes no promise about when the tests will be executed - it is possible to change the implementation so that the factory method is called and the dynamic tests are executed much later. I think this is a good thing and maybe should even be documented. If you share that view, any implementation of this feature should make sure to not accidentally rely on the immediacy of the test execution, thus locking JUnit into that behavior. (I realized all of this when looking at your idea for how to implement the time out.) |
Too many concerns and open ends with #838 "we should think it over more and brainstorm about the user experience and programming model before doing any actual coding. In other words, we need to design the feature first." |
I bumped into this issue when attempted to build a prototype of early termination of tests in a container once a failed one is discovered in pitest-junit5-plugin. Pitest, a mutation coverage tool, runs tests against a mutation of the code they cover to determine if these tests are good enough — if they detect mutants. When it runs a parameterized or dynamic JUnit 5 test and detects a test failure, there is usually no need to run subsequent tests — but that is controlled by Pitest configuration. The workaround I used involved an extension implementing |
This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. Thank you for your contribution. |
This issue has been automatically closed due to inactivity. If you have a good use case for this feature, please feel free to reopen the issue. |
I would like to have this issue reopened. I am currently writing selenium integration tests and I am using DynamicTests for this purpose to create a logical dynamic workflow in the test. The problem here is if even one of the steps fails it is to be assumed that the following tests will fail too. So it would be great if the |
Dynamic Tests are non-deterministic in nature. Sometimes it might not be clear to the test author (let alone the IDE) when or even if the execution will terminate.
It has been suggested to introduce a timeout to stop the execution before it would terminate by itself. An alternative would be to terminate the execution when a certain number of failed (or successful tests) have been executed.
The text was updated successfully, but these errors were encountered: