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 tests #177

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

Fix flaky tests #177

wants to merge 1 commit into from

Conversation

dserfe
Copy link

@dserfe dserfe commented Oct 25, 2023

This PR is to fix flaky tests caused by tests shared status.

Problem

If test com.github.kevinsawicki.http.HttpRequestTest#customConnectionFactory runs before other tests, such as com.github.kevinsawicki.http.HttpRequestTest#headWithEscapedMappedQueryParams, the latter one will fail:

[ERROR]   HttpRequestTest.headWithEscapedMappedQueryParams:2998 expected:<us er> but was:<null>

A full list of tests that can be polluted by the shared status include 28 tests:

com.github.kevinsawicki.http.HttpRequestTest.putWithEscapedMappedQueryParams
com.github.kevinsawicki.http.HttpRequestTest.putWithEscapedVarargsQueryParams
com.github.kevinsawicki.http.HttpRequestTest.putWithMappedQueryParams
com.github.kevinsawicki.http.HttpRequestTest.putWithVarargsQueryParams
com.github.kevinsawicki.http.HttpRequestTest.singleSslSocketFactory
com.github.kevinsawicki.http.HttpRequestTest.singleVerifier
com.github.kevinsawicki.http.HttpRequestTest.basicProxyAuthentication
com.github.kevinsawicki.http.HttpRequestTest.deleteWithEscapedMappedQueryParams
com.github.kevinsawicki.http.HttpRequestTest.deleteWithEscapedVarargsQueryParams
com.github.kevinsawicki.http.HttpRequestTest.deleteWithMappedQueryParams
com.github.kevinsawicki.http.HttpRequestTest.deleteWithVarargsQueryParams
com.github.kevinsawicki.http.HttpRequestTest.getUrlEncodedWithPercent
com.github.kevinsawicki.http.HttpRequestTest.getUrlEncodedWithSpace
com.github.kevinsawicki.http.HttpRequestTest.getUrlEncodedWithUnicode
com.github.kevinsawicki.http.HttpRequestTest.getWithEscapedMappedQueryParams
com.github.kevinsawicki.http.HttpRequestTest.getWithEscapedVarargsQueryParams
com.github.kevinsawicki.http.HttpRequestTest.getWithMappedQueryParams
com.github.kevinsawicki.http.HttpRequestTest.headWithEscapedMappedQueryParams
com.github.kevinsawicki.http.HttpRequestTest.headWithEscapedVarargsQueryParams
com.github.kevinsawicki.http.HttpRequestTest.headWithMappedQueryParams
com.github.kevinsawicki.http.HttpRequestTest.headWithVaragsQueryParams
com.github.kevinsawicki.http.HttpRequestTest.postWithEscapedMappedQueryParams
com.github.kevinsawicki.http.HttpRequestTest.postWithEscapedVarargsQueryParams
com.github.kevinsawicki.http.HttpRequestTest.postWithNumericQueryParams
com.github.kevinsawicki.http.HttpRequestTest.verifierAccepts
com.github.kevinsawicki.http.HttpRequestTest.getWithVarargsQueryParams
com.github.kevinsawicki.http.HttpRequestTest.postWithMappedQueryParams
com.github.kevinsawicki.http.HttpRequestTest.postWithVaragsQueryParams

Root cause and fix

The test failure is caused by the shared status pollution from com.github.kevinsawicki.http.HttpRequestTest#customConnectionFactory, it sets a new ConnectionFactory but doesn't reset its status at the end of the test, thus leads to other test failures. To clear the pollution, we should reset the ConnectionFactory in teardown methods.

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