Skip to content

Conversation

bee0511
Copy link

@bee0511 bee0511 commented Sep 29, 2025

What changed

Replaced containsExactly(...) with containsOnly(...) to avoid assuming deterministic field order in rows/Maps.

Why

The test failed intermittently because Map iteration order is not guaranteed. NonDex exposed this by randomizing iteration order.

How to reproduce

Run the test repeatedly with NonDex:

mvn -pl . edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=examples.kotlin.mybatis3.joins.DeprecatedJoinMapperTest -Drat.skip

You will see failures like:

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.944 s <<< FAILURE! -- in examples.kotlin.mybatis3.joins.DeprecatedJoinMapperTest
examples.kotlin.mybatis3.joins.DeprecatedJoinMapperTest.testFullJoinWithoutAliases -- Time elapsed: 0.419 s <<< FAILURE!
java.lang.AssertionError: 

Actual and expected have the same elements but not in the same order, at index 0 actual element was:
  "QUANTITY"=6
whereas expected element was:
  "ORDER_ID"=2

	at examples.kotlin.mybatis3.joins.DeprecatedJoinMapperTest.testFullJoinWithoutAliases(DeprecatedJoinMapperTest.kt:284)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

How tested

Verified with the same NonDex runs; no further order-related failures occurred.

Tests fixed

examples.kotlin.mybatis3.joins.DeprecatedJoinMapperTest.testFullJoinWithoutAliases
examples.kotlin.mybatis3.joins.DeprecatedJoinMapperTest.testLeftJoinWithAliases
examples.kotlin.mybatis3.joins.DeprecatedJoinMapperTest.testLeftJoinWithoutAliases
examples.kotlin.mybatis3.joins.DeprecatedJoinMapperTest.testLeftJoinWithSubQuery
examples.kotlin.mybatis3.joins.DeprecatedJoinMapperTest.testRightJoinWithAliases
examples.kotlin.mybatis3.joins.DeprecatedJoinMapperTest.testRightJoinWithoutAliases
examples.kotlin.mybatis3.joins.DeprecatedJoinMapperTest.testRightJoinWithSubQuery

@bee0511
Copy link
Author

bee0511 commented Sep 30, 2025

I found other tests within this class also have similar issue. I will update the PR information.

@bee0511 bee0511 changed the title Fix flaky test DeprecatedJoinMapperTest.testFullJoinWithoutAliases Fix flaky test DeprecatedJoinMapperTest Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant