Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SnippetsTests #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

epicgamer1234
Copy link

What this pull request does

This pull request fixes the flaky test SnippetsTests.pick_should_pick_key_pairs_corresponding_to_keys. The test passes sometimes and fails other times because the Snippets.pick method does not preserve the order of elements in a list, while the test assumes a specific order.

Why the test is flaky

The containsExactly method assumes that the map groups will have a specific order, but theSnippets.pick method can return a map with elements in any order.

How the test was fixed

The test can be fixed by replacing containsExactly with containsOnly, which does not assume a specific order.

Reproduce the test failure

Run the tests with the NonDex maven tool and use the following command:
mvn -e -pl . edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=snippets.SnippetsTests#pick_should_pick_key_pairs_corresponding_to_keys
Fixing the flaky test now may prevent flaky test failures in future Java versions.

Result from testing

We get the following failure:
[ERROR] pick_should_pick_key_pairs_corresponding_to_keys(snippets.SnippetsTests) Time elapsed: 0.039 s <<< FAILURE! java.lang.AssertionError: Actual and expected have the same elements but not in the same order, at index 0 actual element was: <MapEntry[key="c", value=3]> whereas expected element was: <a=1>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant