fix flaky test br.com.helpdev.quaklog.entity.GameTest#shouldBuildGameWithSuccess #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The test
test br.com.helpdev.quaklog.entity.GameTest#shouldBuildGameWithSuccess
asserts the players which are stored in the game. These are stored in a List. The list is generated by the builder using a map. But the order, in which the players are returned by the map, is not deterministic, but the test expects the values to be in certain order.This leads to a flaky test.
quaklog-api/core/src/test/java/br/com/helpdev/quaklog/entity/GameTest.java
Lines 38 to 39 in f651f2a
quaklog-api/core/src/main/java/br/com/helpdev/quaklog/entity/Game.java
Line 27 in f651f2a
This problem was found by the NonDex Engine.
Solution
Sort the stream of players in the map by their ID, to make sure, they are returned in predefined order.
quaklog-api/core/src/main/java/br/com/helpdev/quaklog/entity/Game.java
Lines 29 to 30 in b76c148
Reproduce
To reproduce, follow the steps:
./gradlew build -x test
apply plugin: 'edu.illinois.nondex'
subprojects { apply plugin: 'edu.illinois.nondex' }