2

I have two different sets of parameter sources for a parameterized test (set 1 being a subset of set 2). Depending on JUnit5 tags I want to execute the same test method either against set 1 or set 2.

Unfortunately neither the annotation @ParameterizedTest nor @MethodSource allow to specify a tag.

Obviously I can define two different test methods which have the same functionality but act on different parameter sets but that is very redundant/verbose. Isn't there a more elegant way?

1
  • Similar to this question. What you could do: add a TestInfo parameter to your @MethodSource, it will be automatically resolved. You can then check testInfo.getTags().contains(...). Note that since @MethodSource is static, this will only work for tags on the class level. But anyway, would you mind adding some sample code? Commented Sep 11, 2023 at 18:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.