braintree / braintree_java

Braintree Java library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
158 stars 99 forks source link

Fix a flaky test. #99

Closed LALAYANG closed 3 years ago

LALAYANG commented 3 years ago
  1. The test failure:

    • Run the test com.braintreegateway.unittest.RequestBuilderTest#map with mvn edu.illinois:nondex-maven-plugin:1.1.2:nondex -Dtest=com.braintreegateway.unittest.RequestBuilderTest#map
    • Get some failures:
      [ERROR] Failures:
      [ERROR] RequestBuilderTest.map:53 expected: <<examples><color>green</color><insect>bee</insect></examples>> but was: <<examples><insect>bee</insect><color>green</color></examples>>
    • About NonDex.
  2. Why it fails:

    • In src/test/java/com/braintreegateway/unittest/RequestBuilderTest.java : Map<String, Object> map = new HashMap<String, Object>(); HashMap makes no guarantee about the iteration order.
  3. Fix it:

    • By changing HashMap to LinkedHashMap.
kate-paypal commented 3 years ago

This change has been accepted and will be in the next release.