-
Notifications
You must be signed in to change notification settings - Fork 62
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
base: main
Are you sure you want to change the base?
feat: Add dedicated annotations for boolean, String, int and double flags in Junit5 extension #1478
Conversation
| @Test | ||
| @BooleanFlag(name = FLAG, value = true) | ||
| @BooleanFlag(name = FLAG, value = false) | ||
| void duplicatedTypedFlagsSimple() { |
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.
Please use more descriptive names for your tests, maybe something like duplicateFlagKeyOverridesPreviousDeclaration
|
@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]>
d53dc31 to
6777d82
Compare
| } | ||
|
|
||
| @Test | ||
| @DoubleFlag(name = FLAG, value = 1.d) |
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.
| @DoubleFlag(name = FLAG, value = 1.d) | |
| @DoubleFlag(name = FLAG, value = FLAG_VALUE) |
also for the other tests
| 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; | ||
| } |
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.
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.
| @BooleanFlag(name = FLAG, value = false) | ||
| void duplicatedTypedFlagDoesntOverridePrevious() { | ||
| Client client = OpenFeatureAPI.getInstance().getClient(); | ||
| assertThat(client.getBooleanValue(FLAG, false)).isTrue(); |
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.
Reading the annotations I would have expected the last definition of FLAG to win and resolve to false.
Is this the same behavior as with multiple @Flag annotations?
| @BooleanFlag(name = FLAG, value = true) | ||
| void existingSimpleTypedFlagIsRetrieved() { | ||
| Client client = OpenFeatureAPI.getInstance().getClient("testSpecific"); | ||
| assertThat(client.getBooleanValue(FLAG, false)).isTrue(); |
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.
What does this test do? FLAG is defined on Class and Method level, both with true.
| @Test | ||
| @Flag(name = FLAG, value = "true") | ||
| @BooleanFlag(name = FLAG, value = true) | ||
| void simpleConfigDuplicateFlags() { |
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.
Interesting, that defining FLAG twice as simple flag and type flag on the method level throws, an exception, but a simple flag FLAG on class level and a typed flag FLAG on method level does not throw.
See existingSimpleTypedFlagIsRetrieved() on L143
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.
Just saw, this test class is disabled. Is this tech debt?
This PR
BooleanFlag,StringFlag,IntegerFlag, andDoubleFlagfor more specific and type-safe flag definitions in JUnit testsRelated Issues
Fixes #923
Notes
Not sure about tests, feedback on the test coverage is very welcome!