datasource-assert
datasource-assert copied to clipboard
Fix flaky test testParamsByNameUnmatchedMessage()
PR Overview
The PR proposes a fix for the following tests - net.ttddyy.dsproxy.asserts.hamcrest.ParameterHolderAssertionsTest#testParamsByNameUnmatchedMessage
Build Project
- To build the project :
mvn clean install
- To run the test :
mvn test
- To run the nondex tool on this test :
mvn edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=<path.to.test#testName>
Problem
This flakiness was identified by the nondex tool created by the researchers of UIUC. The above eight tests fail when run on the nondex tool.
This test uses a map with keys foo
and bar
and is being asserted that the order must be with keys bar
and foo
. Simply changing the order of insertion of the map values will not solve this since the map still does not maintain order of insertion and there are possibilities this can fail again in the same way
https://github.com/ttddyy/datasource-assert/blob/2cf1ad31948e4e18b60483b67417ab68e61ffc10/src/test/java/net/ttddyy/dsproxy/asserts/hamcrest/ParameterHolderAssertionsTest.java#L113-L126
Fix:
The proposed fix is to use a LinkedHashMap
instead of a map since it will maintain the order of insertion