-
Notifications
You must be signed in to change notification settings - Fork 50
test: Consolidate test providers #1661
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
test: Consolidate test providers #1661
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1661 +/- ##
=======================================
Coverage ? 93.20%
Complexity ? 520
=======================================
Files ? 51
Lines ? 1265
Branches ? 112
=======================================
Hits ? 1179
Misses ? 50
Partials ? 36
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
3001b95
to
15363e0
Compare
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.
Pull Request Overview
This PR consolidates multiple test providers into a single TestProvider
class with a comprehensive builder pattern for different testing scenarios. The change simplifies test infrastructure by replacing several specialized provider classes with one configurable provider.
Key Changes
- Introduces a new unified
TestProvider
with a fluent builder pattern that supports various test configurations - Removes several specialized test provider classes (
TestEventsProvider
,DoSomethingProvider
,AlwaysBrokenWithExceptionProvider
, etc.) - Updates the
Flag
class to include immutable fields and flag metadata support
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
src/test/java/dev/openfeature/sdk/testutils/testProvider/TestProvider.java |
New consolidated test provider with builder pattern supporting various test scenarios |
src/test/java/dev/openfeature/sdk/testutils/testProvider/FlagEvaluation.java |
Helper class to track flag evaluations for testing |
src/test/java/dev/openfeature/sdk/e2e/Flag.java |
Enhanced Flag class with immutable fields and metadata support |
Multiple test files | Updated to use the new TestProvider instead of removed provider classes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
for (int i = 0; i < hooks.length; i++) { | ||
this.hooks.add(hooks[i]); |
Copilot
AI
Oct 14, 2025
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.
Use enhanced for-loop instead of traditional for-loop for better readability and performance. Replace with for (Hook hook : hooks) { this.hooks.add(hook); }
for (int i = 0; i < hooks.length; i++) { | |
this.hooks.add(hooks[i]); | |
for (Hook hook : hooks) { | |
this.hooks.add(hook); |
Copilot uses AI. Check for mistakes.
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.
better performance? 🤔
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.
lol I'm skeptical.
src/test/java/dev/openfeature/sdk/testutils/testProvider/TestProvider.java
Show resolved
Hide resolved
src/test/java/dev/openfeature/sdk/testutils/testProvider/TestProvider.java
Show resolved
Hide resolved
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.
Code Review
This pull request introduces a significant improvement to the test suite by consolidating various test providers into a single, highly configurable TestProvider
using a builder pattern. This refactoring greatly enhances the readability, maintainability, and flexibility of the tests. The changes are well-implemented across the codebase. My review includes a suggestion to align the behavior of the new TestProvider
with the OpenFeature specification regarding the resolution reason
when returning a default value.
src/test/java/dev/openfeature/sdk/testutils/testProvider/TestProvider.java
Show resolved
Hide resolved
assertThat(evaluationDetails).isNotNull(); | ||
assertThat(evaluationDetails.getErrorCode()).isNull(); | ||
assertThat(evaluationDetails.getReason()).isEqualTo("DEFAULT"); | ||
assertThat(evaluationDetails.getReason()).isEqualTo(Reason.STATIC.name()); |
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.
This assertion was changed to STATIC
to match the new TestProvider
's behavior. With the suggested change in TestProvider
to return DEFAULT
reason when allowUnknownFlags
is true, this test should assert for DEFAULT
reason.
assertThat(evaluationDetails.getReason()).isEqualTo(Reason.STATIC.name()); | |
assertThat(evaluationDetails.getReason()).isEqualTo(Reason.DEFAULT.name()); |
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.
Generally i do not have strong opinions, as long as the tests continue to work as they should. the changes seem minimal, but I am not sure if this is a needed improvement, but i also do not have strong opinions against it ;). maybe some static variables to make it easy to get a ready
provider etc. (those which are used often) would be cool.
Signed-off-by: christian.lutnik <[email protected]>
Signed-off-by: christian.lutnik <[email protected]>
Signed-off-by: christian.lutnik <[email protected]>
0b31104
to
c805837
Compare
|
I think we have a lot of test support files and I myself have already been annoyed with the different test providers so I'm in favor of this. |
Consolidates all of our test providers into one, which covers all their functionality. Different behaviors can be selected through a builder pattern, that guides the user through the different options