fix flaky test br.com.helpdev.quaklog.entity.GameTest#shouldBuildGameWithSuccess#6
Open
hofi1 wants to merge 1 commit intogbzarelli:masterfrom
Open
fix flaky test br.com.helpdev.quaklog.entity.GameTest#shouldBuildGameWithSuccess#6hofi1 wants to merge 1 commit intogbzarelli:masterfrom
hofi1 wants to merge 1 commit intogbzarelli:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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#shouldBuildGameWithSuccessasserts 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 testbuildscript { repositories { maven { url = uri('https://plugins.gradle.org/m2/') } } dependencies { classpath('edu.illinois:plugin:2.1.1') } }apply plugin: 'edu.illinois.nondex'subprojects { apply plugin: 'edu.illinois.nondex' }