-
Notifications
You must be signed in to change notification settings - Fork 41
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
[Junit5 extension] Run test multiple times for the same flag with different values #957
Comments
theory crafting: @FlagTest( name = "<flagName>", values = {"true", "false"}) |
@UtkarshSharma2612 you might like this. |
Sure let me check this |
Hey @aepfli I understood the requirement a bit, I wanted to know do we want to change the existing testcases or write new testcases for all the providers with this custom annotation. |
It is about adding another Test Annotation, so people who want to write unit tests to test all kinds of variations with one feature flag can use it. maybe some people want to verify, that the code works the same in both cases and is not effected. eg. currently people would need to write two tests for a boolean to check if the code behaves as expected: @Test
@Flag(name = "BOOLEAN_FLAG", value = "true")
void trueCase() {
// your test code
}
@Test
@Flag(name = "BOOLEAN_FLAG", value = "false")
void falseCase() {
// your test code
} instead of this they code do @FlagTest(name = "BOOLEAN_FLAG", values = { "true", "false" })
void bothCases() {
// this block will run twice, once for 'true' and once for 'false'
} does this make somewhat sense? - this is only about testing openFeature functionality with junit |
Okay so we want to create a annotation or something that takes two parameters name (string) and values (List) and runs test cases for all the values. Correct me if I am wrong. |
if you do need more guidance or pointers let me know, some people like the challenge of figuring things out on their own, some want more pointers, and i don't want to spoil the fun for you, if you like to dig on your own ;) |
Sometimes, you want to ensure that your code behaves the same way for all code paths, even if different feature flags are involved.
Junit5 has parameterized tests to run multiple tests based on a source. This approach is not feasible for us, as it only generates an array of possible argument sets.
We need to find a way (maybe with our annotation) to create such tests. The cartesian test extension of JUnit Pioneer can be an inspiration for this https://github.com/junit-pioneer/junit-pioneer/blob/main/src/main/java/org/junitpioneer/jupiter/cartesian/CartesianTest.java
The text was updated successfully, but these errors were encountered: