Skip to content

fix flaky test TimeTest.testBetweenWithMask#1790

Merged
asolntsev merged 1 commit intomainfrom
fix/flaky-time-test
Apr 5, 2026
Merged

fix flaky test TimeTest.testBetweenWithMask#1790
asolntsev merged 1 commit intomainfrom
fix/flaky-time-test

Conversation

@asolntsev
Copy link
Copy Markdown
Collaborator

Sometimes the test failed when

  • "moment + 1 second" appeared to be in tomorrow, or
  • "moment - 1 second" appeared to be in yesterday

Example of failed build:
https://github.com/datafaker-net/datafaker/actions/runs/23998847901/job/69991488685?pr=1789

Expecting actual:
  23:59:22
to be strictly before:
  00:00:00.106916777

	at net.datafaker.providers.base.TimeTest.testBetweenWithMask(TimeTest.java:107)

Sometimes the test failed when
* "moment + 1 second" appeared to be in tomorrow, or
* "moment - 1 second" appeared to be in yesterday

Example of failed build:
https://github.com/datafaker-net/datafaker/actions/runs/23998847901/job/69991488685?pr=1789

```
Expecting actual:
  23:59:22
to be strictly before:
  00:00:00.106916777

	at net.datafaker.providers.base.TimeTest.testBetweenWithMask(TimeTest.java:107)
```
@asolntsev asolntsev added this to the 2.6.0 milestone Apr 5, 2026
@asolntsev asolntsev self-assigned this Apr 5, 2026
@asolntsev asolntsev added the enhancement New feature or request label Apr 5, 2026
@what-the-diff
Copy link
Copy Markdown

what-the-diff bot commented Apr 5, 2026

PR Summary

  • Simplified Time Unit Conversion
    Imported DAYS and MINUTES from java.util.concurrent.TimeUnit, streamlining the process of converting these units into seconds. This makes our code more precise and comprehensible.

  • Updated Time Generating Method for Testing
    The testBetweenWithMask method, which generates a random moment in time for testing purposes, has been revised to use seconds instead of nanoseconds. This results in more manageable data within our tests.

  • Improved Assertions in Testing Method
    The assertions (checks to verify certain conditions are met) within the testBetweenWithMask method have been updated to use isAfterOrEqualTo and isBeforeOrEqualTo. This allows for a broader time range during checks, ensuring our tests cover all possible scenarios.

@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.39%. Comparing base (47f4512) to head (295c42b).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1790      +/-   ##
============================================
+ Coverage     92.28%   92.39%   +0.10%     
- Complexity     3445     3448       +3     
============================================
  Files           339      339              
  Lines          6794     6794              
  Branches        670      670              
============================================
+ Hits           6270     6277       +7     
+ Misses          356      353       -3     
+ Partials        168      164       -4     

☔ 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 merged commit 4117c61 into main Apr 5, 2026
13 checks passed
@asolntsev asolntsev deleted the fix/flaky-time-test branch April 5, 2026 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants