Fixed 35 different flaky tests with ID category#4783
Fixed 35 different flaky tests with ID category#4783xinying-7 wants to merge 3 commits intoswagger-api:masterfrom
Conversation
fixing flaky test serializeDoubleProperty fix flaky test testFormatOfBigDecimal fix flaky test testExtensionObjectWithProperties fix flaky test serializeReadOnlyStringProperty fix flaky test serializeArrayModel fix flaky test deserializeArrayModel fix flaky test serializeArrayStringProperty fix flaky test deserializeArrayStringProperty fix flaky test serializeDateTimeProperty fix flaky test deserializeDateTimeProperty fix flaky test serializeObjectPropertyWithRequiredProperties fix flaky test serializeLongMapProperty fix flaky test deserializeLongMapProperty fixed flaky test deserializeIntegerProperty fixed 9 flaky tests in PropertySerializationTest.java: 'deserializeNotReadOnlyStringProperty', 'deserializeIntegerMapProperty', 'serializeFloatProperty', 'deserializeDoubleProperty', 'serializeIntegerProperty', 'serializeLongProperty', 'deserializeLongProperty', 'deserializeFloatProperty', 'serializeIntegerMapProperty'
|
The previous comment is for the majority of test cases. Here's some specialized tests which I used different approach to fix: For test case For test case For test case |
These tests are failing NonDex since they're directly comparing JSON Strings which can have different key order when run multiple times.
Click on to see more details on the error message
All the tests I fixed have similar issues, so reproducing them requires similar steps. For example, for the
testFormatOfDecimalfunction located inio/swagger/v3/core/converting/NumericFormatTest.java, Here's the steps to reproduce:Run this at the root directory:
mvn -pl modules/swagger-core edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=io.swagger.v3.core.converting.NumericFormatTest#testFormatOfDecimal -DnondexRuns=1(Note: The failing test might not be seen if every test happens to have the JSON string in the correct order. Try running it several times or increase the the number of runs with
-DnondexRuns=to reproduce the issue.)To fix this, I converted the actual and expected JSON String into JSON objects and compare with
JSONAssert.assertEquals, which ensures correct equality checks regardless of key order.