Skip to content

Commit af9cf14

Browse files
committed
Fixed flaky test-case in the following class:
ConsumerJsonRecordTest.should_serialize_a_record_with_headers POINT OF FAILURE -> random attribute ordering in hashmap Fixed using NonDex, plugin added in parent pom. Suggested command to check flaky tests : > mvn nondex:nondex For particular test: >mvn -pl ./core nondex:nondex -Dtest=org.jsmart.zerocode.core.kafka.receive.message.ConsumerJsonRecordTest#should_serialize_a_record_with_headers -DnondexRuns=10 For more information : https://github.com/TestingResearchIllinois/NonDex
1 parent 9b5c7a6 commit af9cf14

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

core/src/test/java/org/jsmart/zerocode/core/kafka/receive/message/ConsumerJsonRecordTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
import com.fasterxml.jackson.databind.JsonNode;
55
import com.fasterxml.jackson.databind.ObjectMapper;
66
import org.hamcrest.CoreMatchers;
7-
import org.hamcrest.Matcher;
87
import org.jsmart.zerocode.core.di.provider.ObjectMapperProvider;
98
import org.junit.Test;
109

1110
import java.io.IOException;
12-
import java.util.HashMap;
11+
import java.util.LinkedHashMap;
1312
import java.util.Map;
1413

1514
import static org.hamcrest.MatcherAssert.assertThat;
@@ -49,7 +48,7 @@ public void should_serialize_a_record_with_headers() throws JsonProcessingExcept
4948
// given
5049
JsonNode key = objectMapper.readTree("123");
5150
JsonNode value = objectMapper.readTree("\"val\"");
52-
Map<String, String> headers = new HashMap<>();
51+
Map<String, String> headers = new LinkedHashMap<>();
5352
headers.put("hKey", "hValue");
5453
headers.put("hKeyWithNullValue", null);
5554
ConsumerJsonRecord record = new ConsumerJsonRecord(key, value, headers);

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,11 @@
376376
<artifactId>maven-dependency-plugin</artifactId>
377377
<version>${maven-dependency-plugin.version}</version>
378378
</plugin>
379+
<plugin> <!-- for flaky testing -->
380+
<groupId>edu.illinois</groupId>
381+
<artifactId>nondex-maven-plugin</artifactId>
382+
<version>2.1.7</version>
383+
</plugin>
379384
</plugins>
380385
</pluginManagement>
381386

0 commit comments

Comments
 (0)