Refactor BaseFakerTest (provider list test)#1607
Conversation
…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.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
BaseFakerTestinto a newProviderListTest<T>class - Makes
BaseFakerTestextendProviderListTest<BaseFaker>with a finalgetFaker()method - Updates all test classes to either extend
BaseFakerTestdirectly orProviderListTest<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.
|
@asolntsev want to accept any of those suggestions? |
|
Thanks! |
Fix IDEA warning "call to overridable method during object construction" in
BaseFakerTest.Now method
getFaker()is final.BaseFakerTestand use protected finalfakerfield.ProviderListTest<T>and implement methodgetFaker().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).