Skip to content

Refactor BaseFakerTest (provider list test)#1607

Merged
kingthorin merged 2 commits intomainfrom
refactoring/provider-list-test
Aug 13, 2025
Merged

Refactor BaseFakerTest (provider list test)#1607
kingthorin merged 2 commits intomainfrom
refactoring/provider-list-test

Conversation

@asolntsev
Copy link
Copy Markdown
Collaborator

@asolntsev asolntsev commented Aug 13, 2025

Fix IDEA warning "call to overridable method during object construction" in BaseFakerTest.

Now method getFaker() is final.

  1. Most classes just extend BaseFakerTest and use protected final faker field.
  2. Classes that actually need a custom faker extend ProviderListTest<T> and implement method getFaker().

P.S. I think it's still not a perfect solution. Most of these tests actually need to provide list of Fakers (at least with different locales).

…on" in BaseFakerTest

Now method `getFaker()` is final.

1. Most classes just `extend BaseFakerTest` and use protected `faker` field
2. Classes that actually need a custom faker `extend ProviderListTest<T>` and implement method `getFaker()`.

P.S. I think it's still not a perfect solution. Most of these tests actually need to provide list of Fakers (at least with different locales).
.. to avoid wasting memory on generating unneeded string.
@asolntsev asolntsev added this to the 2.4.5 milestone Aug 13, 2025
@asolntsev asolntsev requested a review from snuyanzin August 13, 2025 19:55
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.42%. Comparing base (22730b5) to head (c2486ed).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1607      +/-   ##
============================================
+ Coverage     92.38%   92.42%   +0.04%     
- Complexity     3355     3358       +3     
============================================
  Files           331      331              
  Lines          6618     6618              
  Branches        655      655              
============================================
+ Hits           6114     6117       +3     
  Misses          346      346              
+ Partials        158      155       -3     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@asolntsev asolntsev self-assigned this Aug 13, 2025
Copy link
Copy Markdown
Collaborator

@kingthorin kingthorin left a comment

Choose a reason for hiding this comment

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

LGTM

@kingthorin kingthorin requested a review from Copilot August 13, 2025 20:31
Copy link
Copy Markdown
Contributor

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 refactors the test class hierarchy to fix an IDEA warning about calling overridable methods during object construction. The solution introduces a new ProviderListTest class and makes the getFaker() method in BaseFakerTest final.

Key changes:

  • Extracts the test functionality from BaseFakerTest into a new ProviderListTest<T> class
  • Makes BaseFakerTest extend ProviderListTest<BaseFaker> with a final getFaker() method
  • Updates all test classes to either extend BaseFakerTest directly or ProviderListTest<T> for custom faker implementations

Reviewed Changes

Copilot reviewed 100 out of 100 changed files in this pull request and generated 5 comments.

File Description
src/test/java/net/datafaker/providers/base/ProviderListTest.java New base test class containing the provider list testing logic
src/test/java/net/datafaker/providers/base/BaseFakerTest.java Simplified to extend ProviderListTest with final getFaker() method
Multiple test files Updated to extend BaseFakerTest without generic parameters or ProviderListTest for custom fakers
src/test/java/net/datafaker/script/ProviderGenerator.java Updated type references from BaseFakerTest to ProviderListTest

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@kingthorin
Copy link
Copy Markdown
Collaborator

@asolntsev want to accept any of those suggestions?

@kingthorin kingthorin merged commit a47a024 into main Aug 13, 2025
13 checks passed
@kingthorin kingthorin deleted the refactoring/provider-list-test branch August 13, 2025 21:15
@kingthorin
Copy link
Copy Markdown
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants