Commit d9669c3
committed
fix flaky test
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`.TimeAndDateTest.testFutureDateWithBounds
1 parent 2729350 commit d9669c3
1 file changed
Lines changed: 1 addition & 1 deletion
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
0 commit comments