Commit a69e198
authored
Fix: flaky tests of set comparison (#3104)
The flaky tests below were found with [NonDex](https://github.com/TestingResearchIllinois/NonDex), which explores non-determinism in tests. These tests can fail due to different iteration orders under different JVMs, hash seeds, etc.
- `AbstractValueTest.shouldConvertToJavaSetUsingSupplier`
- `AbstractValueTest.shouldConvertToJavaSet`
- `AbstractTraversableTest.shouldConvertNonNilToHashSet`
The `assertThat(Iterable<T>)` returns an `IterableAssert`, even when we pass a Set. The comparator `isEqualTo(...)` for `IterableAssert` is order-sensitive and can iterate through the sets in different orders.
Use `containsExactlyInAnyOrderElementsOf` from assertJ, which is order-insensitive.
The fix only modifies test code, but not production code.
### Failure Reproduction
- Java version:
```
openjdk 17.0.16 2025-07-15
OpenJDK Runtime Environment (build 17.0.16+8-Ubuntu-0ubuntu124.04.1)
OpenJDK 64-Bit Server VM (build 17.0.16+8-Ubuntu-0ubuntu124.04.1, mixed mode, sharing)
```
- OS version:
`Ubuntu 24.04.3 LTS`
Build the module and run tests with [NonDex](https://github.com/TestingResearchIllinois/NonDex), for example:
```
mvn edu.illinois:nondex-maven-plugin:2.1.7:nondex -pl vavr \
-Dtest=IteratorTest#shouldConvertToJavaSetUsingSupplier \
-Djacoco.skip -Drat.skip -Dpmd.skip -Denforcer.skip
```1 parent ae2ab78 commit a69e198
File tree
2 files changed
+5
-5
lines changed- vavr/src/test/java/io/vavr
- collection
2 files changed
+5
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
804 | 804 | | |
805 | 805 | | |
806 | 806 | | |
807 | | - | |
| 807 | + | |
808 | 808 | | |
809 | | - | |
| 809 | + | |
810 | 810 | | |
811 | 811 | | |
812 | 812 | | |
| |||
815 | 815 | | |
816 | 816 | | |
817 | 817 | | |
818 | | - | |
| 818 | + | |
819 | 819 | | |
820 | | - | |
| 820 | + | |
821 | 821 | | |
822 | 822 | | |
823 | 823 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2601 | 2601 | | |
2602 | 2602 | | |
2603 | 2603 | | |
2604 | | - | |
| 2604 | + | |
2605 | 2605 | | |
2606 | 2606 | | |
2607 | 2607 | | |
| |||
0 commit comments