Skip to content

Conversation

chrfwow
Copy link
Contributor

@chrfwow chrfwow commented Oct 8, 2025

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

Copy link

codecov bot commented Oct 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@110054f). Learn more about missing BASE report.
⚠️ Report is 1 commits behind head on main.

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           
Flag Coverage Δ
unittests 93.20% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chrfwow chrfwow force-pushed the consolidate-test-providers branch from 3001b95 to 15363e0 Compare October 14, 2025 09:20
@chrfwow chrfwow marked this pull request as ready for review October 14, 2025 09:41
@chrfwow chrfwow requested review from a team as code owners October 14, 2025 09:41
@chrfwow chrfwow requested a review from Copilot October 14, 2025 09:42
Copy link

@Copilot Copilot AI left a 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.

Comment on lines +273 to +274
for (int i = 0; i < hooks.length; i++) {
this.hooks.add(hooks[i]);
Copy link

Copilot AI Oct 14, 2025

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); }

Suggested change
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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

better performance? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

lol I'm skeptical.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

assertThat(evaluationDetails).isNotNull();
assertThat(evaluationDetails.getErrorCode()).isNull();
assertThat(evaluationDetails.getReason()).isEqualTo("DEFAULT");
assertThat(evaluationDetails.getReason()).isEqualTo(Reason.STATIC.name());
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
assertThat(evaluationDetails.getReason()).isEqualTo(Reason.STATIC.name());
assertThat(evaluationDetails.getReason()).isEqualTo(Reason.DEFAULT.name());

Copy link
Member

@aepfli aepfli left a 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]>
@toddbaert toddbaert force-pushed the consolidate-test-providers branch from 0b31104 to c805837 Compare October 20, 2025 17:51
Copy link

@toddbaert
Copy link
Member

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.

@toddbaert toddbaert merged commit d7dfc06 into open-feature:main Oct 20, 2025
13 checks passed
@chrfwow chrfwow deleted the consolidate-test-providers branch October 21, 2025 06:30
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.

3 participants