-
-
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
Implement Parallel Method Execution in JUnit-Vintage engine #4242
base: main
Are you sure you want to change the base?
Conversation
I created this Draft PR to ask a few questions. However, I have a question regarding their behavior:
|
62d4652
to
0cd9f4d
Compare
I think we should check for that, log a warning (like we do for invalid configuration parameters in Jupiter), and continue as if
I think turning off parallel execution (using the |
Issue: junit-team#4058
Done in be5234f ! |
b09c55e
to
36ac248
Compare
36ac248
to
0b70615
Compare
I implemented this to get feedback on parallelization at the class and method levels. 0b70615
There are three scenarios when running parallel tests:
I want to design it similarly to JUnit 4's ParallelComputer, but I need help..🥹 |
executorService.shutdown(); | ||
executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think shutting down the thread pool here is not correct because this will be called for each runner plus we're also using it if classes
is true
as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the comment you provided.
Based on that, I removed the shutdown
and only used the awaitTermination
method.
Then, I added a conditional statement to check if it completes within the given time. e92e834
Upon testing, I found that not all tests finished within the specified time.
As a result, I implemented the finished
method to do nothing, but this caused the assertion comparing the start and end times to fail.
Could you provide a hint about what kind of work might need to be done inside the finished
method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to wait for all futures scheduled for a particular runner. I have addressed that in the commit I've pushed to your branch just now.
...t-vintage-engine/src/main/java/org/junit/vintage/engine/descriptor/RunnerTestDescriptor.java
Outdated
Show resolved
Hide resolved
* @since 5.13 | ||
*/ | ||
@API(status = INTERNAL, since = "5.13") | ||
public interface RunnerScheduler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we use org.junit.runners.model.RunnerScheduler
directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Directly using org.junit.runners.model.RunnerScheduler
seems like a good approach.
However, when running the junit-vintage-engine:testWithoutJUnit4
task, an exception occurs because it fails to find org.junit.runners.model.RunnerScheduler
.
- Exception message
* What went wrong:
Execution failed for task ':junit-vintage-engine:testWithoutJUnit4'.
> Failure during test discovery: Forked test JVM terminated unexpectedly with exit value 1
Test Distribution has stopped executing any remaining tests and silently skips them!
For potential reasons why the test JVM exited, check the troubleshooting section at https://gradle.com/help/test-distribution-troubleshooting.
Standard error from JVM:
Terminating due to fatal error
java.lang.NoClassDefFoundError: org/junit/runners/model/RunnerScheduler
at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
So, I’m considering restoring it again. What are your thoughts on that? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a commit that fixes that. Instead of referencing RunnerScheduler
in VintageTestEngine
, it passes ExecutorService
to RunnerTestDescriptor
and creates the RunnerScheduler
in there.
…scriptor/RunnerTestDescriptor.java Co-authored-by: Marc Philipp <[email protected]>
4da4954
to
29e5e11
Compare
Issue: junit-team#4238
29e5e11
to
e92e834
Compare
While writing test code, I discovered an issue caused by using the same
Assumption: Lets assume the thread pool size of the ExecutorService is Scenario:
To prevent this issue, we could either set a timeout on WDYT? I’m also curious whether this issue will be included in version 5.12M1 or 5.13. |
Issue: junit-team#4238
Resolves: #4238
Overview
Implements parallel execution of test methods in the junit-vintage-engine, inspired by the parallelization support available in JUnit 4 through
ParallelComputer
.Changes
I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotations