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

Fixed flaky test case in EmailTest.java #561

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

Conversation

hermya
Copy link

@hermya hermya commented Nov 7, 2024

Fixed flaky test case in the following class: org.simplejavamail.api.email.EmailTest

Assertion called in: EmailTest#testToStringFull

POINT OF FAILURE

In EmailPopulatingBuilderImpl class, headers was of type HashMap. HashMap being unordered, can give non-deterministic results for toString() method when run on different jvms.
Observed failure was:

expectedEmailString ~ "...headers={dummyHeader1=[dummyHeaderValue1], dummyHeader2=[dummyHeaderValue2]}..."
actualEmailString ~ "...headers={dummyHeader2=[dummyHeaderValue2], dummyHeader1=[dummyHeaderValue1]}..."

FIX

Changed the type of headers to LinkedHashMap as it retrieves the order of insertion in the Map, guaranteeing consistent toString() output.

Fixed using NonDex

Suggested command to check flaky tests :

mvn edu.illinois:nondex-maven-plugin:2.1.7:nondex

For the particular test class:

mvn -pl ./modules/simple-java-mail edu.illinois:nondex-maven-plugin:2.1.7:nondex \
-Dmode=ONE \
-DnondexRuns=5  \
-Dtest=org.simplejavamail.api.email.EmailTest#testToStringFull \
-Dossindex.skip=true -Dspotbugs.skip=true \
-Dmaven.javadoc.skip=true -Denforcer.skip=true \
-Djacoco.skip=true -Dlicense.skip=true

For more information: https://github.com/TestingResearchIllinois/NonDex

Failure caused by inconsistent string result from headers.toString() (headers being of type HashMap)
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