Skip to content

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

2897robo
Copy link

This PR improves the documentation for JUnit 5's parallel test execution.

  • Adds a concise example for using the @Execution annotation with ExecutionMode.CONCURRENT.
  • Helps users understand how to opt-in per-class parallel execution.

I hereby agree to the terms of the JUnit Contributor License Agreement.

Issue: #2669

@marcphilipp marcphilipp linked an issue May 13, 2025 that may be closed by this pull request
2 tasks
@2897robo
Copy link
Author

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 @Execution(CONCURRENT) usage as discussed in #2669, and I hope it helps clarify parallel execution configuration for users.

Let me know if anything needs to be updated — happy to revise!

Thanks again for your time and guidance. 🙏

Comment on lines +3198 to +3199
==== Using @Execution Annotation

Copy link
Member

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.

Suggested change
==== Using @Execution Annotation
==== Using @Execution Annotation

Comment on lines +3204 to +3215
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() { ... }
}
Copy link
Member

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
Copy link
Member

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:

Suggested change
@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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
|===

Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve documentation on Parallel Test Execution
2 participants