fix flaky test TimeAndDateTest.testFutureDateWithBounds#1890
Merged
Conversation
Example of test failure: https://github.com/datafaker-net/datafaker/actions/runs/29958635963/job/89060037790?pr=1888 ### The problem The test is using variable `now`: ``` void testFutureDateWithBounds() { Instant now = Instant.now(); System.gc(); // --- GC runs at this moment --- Instant future = timeAndDate.future(1, TimeUnit.SECONDS); assertThat(future).isBetween(now, now.plusSeconds(1)); // -- `future` > `now+1s` } ``` If GC runs exactly at this moment (or JVM gets a bit slower for any reason), the `future` might appear later than `now + 1 second`.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1890 +/- ##
============================================
- Coverage 92.58% 92.55% -0.03%
+ Complexity 3572 3571 -1
============================================
Files 347 347
Lines 7051 7051
Branches 675 675
============================================
- Hits 6528 6526 -2
- Misses 364 365 +1
- Partials 159 160 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
PR Summary
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Example of test failure: https://github.com/datafaker-net/datafaker/actions/runs/29958635963/job/89060037790?pr=1888
The problem
The test is using variable
now:If GC runs exactly at this moment (or JVM gets a bit slower for any reason), the
futuremight appear later thannow + 1 second.