-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Improve documentation on @Execution annotation usage for parallel test execution #4525
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
base: main
Are you sure you want to change the base?
Improve documentation on @Execution annotation usage for parallel test execution #4525
Conversation
Hi @marcphilipp 👋 Just wanted to kindly check in and see if you could review this PR when you have time. It adds a clear example for the Let me know if anything needs to be updated — happy to revise! Thanks again for your time and guidance. 🙏 |
==== Using @Execution Annotation | ||
|
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 don't think a new subsection is necessary here.
==== Using @Execution Annotation | |
==== Using @Execution Annotation | |
import org.junit.jupiter.api.parallel.Execution; | ||
import org.junit.jupiter.api.parallel.ExecutionMode; | ||
|
||
@Execution(ExecutionMode.CONCURRENT) | ||
class MyParallelTests { | ||
|
||
@Test | ||
void testA() { ... } | ||
|
||
@Test | ||
void testB() { ... } | ||
} |
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.
We keep our code snippets in documentation/src/test/java
and include them from there so they're compiled and executed which prevents (most) errors in them. Please rename this class to ExplicitExecutionModeDemo
and move it to the source folder.
@Test | ||
void testA() { ... } | ||
|
||
@Test |
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.
Would be good to also include a method-level example configuring the opposite:
@Test | |
@Test | |
@Execution(ExecutionMode.SAME_THREAD) |
@@ -3195,6 +3195,28 @@ execution order. Thus, in both cases, test methods in such test classes are only | |||
concurrently if the `@Execution(CONCURRENT)` annotation is present on the test class or | |||
method. | |||
|
|||
==== Using @Execution Annotation | |||
|
|||
You can use the `@Execution` annotation to explicitly configure concurrent execution for a test class or 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.
You can use the `@Execution` annotation to explicitly configure concurrent execution for a test class or method: | |
You can use the `@Execution` annotation to explicitly configure the execution mode for a | |
test class or method: |
| Integer (e.g., 4) | ||
| none | ||
|=== | ||
|
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.
There's already a table below listing these (and more) properties. Am I missing something or is this additional table unnecessary?
This PR improves the documentation for JUnit 5's parallel test execution.
@Execution
annotation withExecutionMode.CONCURRENT
.I hereby agree to the terms of the JUnit Contributor License Agreement.
Issue: #2669