Skip to content

feat: Add dedicated annotations for boolean, String, int and double flags in Junit5 extension #1478

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 1 commit into
base: main
Choose a base branch
from

Conversation

ssharaev
Copy link
Member

@ssharaev ssharaev commented Jul 6, 2025

This PR

  • adds dedicated annotations BooleanFlag, StringFlag, IntegerFlag, and DoubleFlag for more specific and type-safe flag definitions in JUnit tests

Related Issues

Fixes #923

Notes

Not sure about tests, feedback on the test coverage is very welcome!

@ssharaev ssharaev requested a review from a team as a code owner July 6, 2025 17:35
@github-actions github-actions bot requested a review from aepfli July 6, 2025 17:36
@Test
@BooleanFlag(name = FLAG, value = true)
@BooleanFlag(name = FLAG, value = false)
void duplicatedTypedFlagsSimple() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use more descriptive names for your tests, maybe something like duplicateFlagKeyOverridesPreviousDeclaration

@chrfwow
Copy link
Contributor

chrfwow commented Jul 7, 2025

@ssharaev you will need to force push a commit that is signed off, otherwise the DCO check will not succeed

…lags in Junit5 extension

Signed-off-by: Sviatoslav Sharaev <[email protected]>
@ssharaev ssharaev force-pushed the feat/new-test-flags-annotations branch from d53dc31 to 6777d82 Compare July 14, 2025 04:20
@@ -29,6 +37,13 @@ void existingSimpleFlagIsRetrieved() {
assertThat(client.getDoubleValue(FLAG, FALLBACK)).isEqualTo(FLAG_VALUE);
}

@Test
@DoubleFlag(name = FLAG, value = 1.d)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@DoubleFlag(name = FLAG, value = 1.d)
@DoubleFlag(name = FLAG, value = FLAG_VALUE)

also for the other tests

Comment on lines +98 to +105
if (domainFlagNames.contains(flagName)) {
throw new IllegalArgumentException("Flag with name " + flagName + " already exists. "
+ "There shouldn't be @Flag and @" + value.getClass().getSimpleName() + "Flag with the same name!");
}

if (domainFlags.containsKey(flagName)) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

One of these checks is redundant. I think we could even remove the domainFlagNames set entirely, as it contains the same information as the domainFlags map.

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.

[Junit5 extension] add dedicated Annotations for Number, Boolean and String flags
3 participants