Skip to content
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 target annotation attribute for @Execution #4368

Open
1 task
marcphilipp opened this issue Mar 5, 2025 · 0 comments
Open
1 task

Introduce target annotation attribute for @Execution #4368

marcphilipp opened this issue Mar 5, 2025 · 0 comments

Comments

@marcphilipp
Copy link
Member

Similar to the target=SELF|CHILDREN attribute added to @ResourceLock in #3102, the @Execution annotation should also receive such an attribute to support the following use cases.

Class level

In this case, using target=CHILDREN would have the same effect as declaring @Execution on every @Test method of the test class.

@Execution(value = CONCURRENT, target = CHILDREN)
class SomeTests {
    @Test
    void test1() {}
    @Test
    void test2() {}
}

would be equivalent to

class SomeTests {
    @Test
    @Execution(CONCURRENT)
    void test1() {}
    @Test
    @Execution(CONCURRENT)
    void test2() {}
}

Annotations on test methods should override annotations on the class level. Therefore, test2 from the following example should use SAME_THREAD while test1 should use CONCURRENT.

@Execution(value = CONCURRENT, target = CHILDREN)
class SomeTests {
    @Test
    void test1() {}
    @Test
    @Execution(SAME_THREAD)
    void test2() {}
}

@TestTemplate and @TestFactory methods

In this case, using target=CHILDREN would unlock a new use case, namely to be able to use a different ExecutionMode for the invocations of a test template or the dynamic tests of a test factory than for the test template/factory container node.

@ParameterizedTest
@ValueSource(ints = { 1, 2 })
@Execution(SAME_THREAD) // optional
@Execution(value = CONCURRENT, target = CHILDREN)
void parameterizedTest() {}

@TestFactory
@Execution(SAME_THREAD) // optional
@Execution(value = CONCURRENT, target = CHILDREN)
Stream<DynamicTest> parameterizedTest() {/* ... */}

Related issues

Deliverables

  • Introduce target attribute and evaluate it when computing the ExecutionMode of a child TestDescriptor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant