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

Fix Flaky Test in SubjectClosureResolver_TestCase #814

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

Conversation

Sitara-a
Copy link

A flaky test was fixed in this pull request-

  1. edu.stanford.bmir.protege.web.server.entity.SubjectClosureResolver_TestCase.shouldGetClsAsRootEntity

Flakiness in the tests -

To check for flakiness in the tests, a tool called nondex was used.

Steps to reproduce flakiness using nondex -

Test 1:

mvn install -pl webprotege-server-api -am -DskipTests
mvn -pl webprotege-server-api test -Dtest=edu.stanford.bmir.protege.web.server.entity.SubjectClosureResolver_TestCase
mvn -pl webprotege-server-api edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=edu.stanford.bmir.protege.web.server.entity.SubjectClosureResolver_TestCase

The third command shows us the flakiness in the test. There are test failures due to differences in the order of elements
Screenshot 2024-10-31 140226

Source of Flakiness in the test and fix:
The object rootEntities is a set and sets in Java have no order. However, the check being carried out was - assertThat(rootEntities, contains(cls, valueEntity));
The contains() method checks if the two objects cls and valueEntity are present in the exact order in which they are mentioned and this fails if the order in the set is different from the order mentioned.

To fix this, contains() is replaced by hasItems() which does not check the order of items.

Code change-
assertThat(rootEntities, hasItems(cls, valueEntity));

Please let me know if you have any questions or need any additional justification/changes from my side.

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.

1 participant