Skip to content

Fix possible issue with tr locale in testUsernameWithSpaces#1669

Merged
snuyanzin merged 2 commits intodatafaker-net:mainfrom
snuyanzin:username
Sep 23, 2025
Merged

Fix possible issue with tr locale in testUsernameWithSpaces#1669
snuyanzin merged 2 commits intodatafaker-net:mainfrom
snuyanzin:username

Conversation

@snuyanzin
Copy link
Copy Markdown
Collaborator

@snuyanzin snuyanzin commented Sep 23, 2025

Current InternetText#testUsernameWithSpaces doesn't take into account possible TR locale

e.g. to make it failing just change a bit input data in a way

    void testUsernameWithSpaces() {
        Name name = mock();
        doReturn("Ivan Ivanov").when(name).firstName();
        doReturn("D'Artagnan").when(name).lastName();

        BaseFaker mockedFaker = new BaseFaker(new Locale("TR")) {
            @Override
            public Name name() {
                return name;
            }
        };
        assertThat(mockedFaker.internet().username())
            .doesNotContain(" ", "'")
            .matches("^(\\w+)\\.(\\w+)$")
            .matches("^\\p{javaLowerCase}+\\.\\p{javaLowerCase}+$");
    }

@what-the-diff
Copy link
Copy Markdown

what-the-diff bot commented Sep 23, 2025

PR Summary

  • Improved Testing Flexibility: The test method testUsernameWithSpaces is now modified to use a parameterized test method with the @MethodSource annotation. This change simplifies the testing process by providing different input combinations directly to the test method.

  • Enhanced Username Testing: We have enhanced the robustness of our testing process by replacing hardcoded username values with dynamic and various inputs. This change allows the testing of multiple combinations of first and last names, leading to more comprehensive results.

  • Included New Data Provider for Tests: A new provider named userNameWithSpacesProvider is implemented to supply varied test data for our enhanced parameterized test. This method ensures a broader variety of data sets for the test, ensuring a robust examination of username functionalities.

  • Refined the Configuration of Faker Mock: We have made refinements in the BaseFaker mock creation by allowing the locale parameter to be dynamic along with the test inputs. This change gives us the flexibility to test username functionality in various locale contexts effectively.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Sep 23, 2025

⚠️ 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.49%. Comparing base (2923e4a) to head (c6941d4).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1669      +/-   ##
============================================
+ Coverage     92.45%   92.49%   +0.03%     
  Complexity     3388     3388              
============================================
  Files           333      333              
  Lines          6697     6688       -9     
  Branches        665      663       -2     
============================================
- Hits           6192     6186       -6     
  Misses          346      346              
+ Partials        159      156       -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 added this to the 2.5.1 milestone Sep 23, 2025
@asolntsev asolntsev added java Pull requests that update Java code refactoring labels Sep 23, 2025
@snuyanzin snuyanzin merged commit f4f8bfc into datafaker-net:main Sep 23, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java Pull requests that update Java code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants