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 HttpUrlConnection androidTests to make them compatible for parallel running #500

Conversation

surbhiia
Copy link
Contributor

@surbhiia surbhiia commented Jul 29, 2024

Improving androidTests to make them compatible for running in parallel:

  • Tested by running them parallel in android studio:
Screenshot parallel run
  • Tested synchronous run:
Screenshot sync run
  • Also tested the actual instrumentation (non test scenario) works as expected.

  • No change for the Okhttp3 androidTests. They run correctly synchronously:

Screenshot okhttp3 sync

@surbhiia surbhiia requested a review from a team July 29, 2024 22:44
@surbhiia surbhiia changed the title Update androidTests to make them compatible for parallel running Update HttpURLconnection androidTests to make them compatible for parallel running Jul 29, 2024
@surbhiia surbhiia changed the title Update HttpURLconnection androidTests to make them compatible for parallel running Update HttpUrlConnection androidTests to make them compatible for parallel running Jul 29, 2024
Copy link
Contributor

@breedx-splk breedx-splk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm struggling with this. I think it's a pretty strong antipattern to mix test code explicitly into the production code, which includes HttpUrlConnectionSingletons. I know we sometimes expand visibility to facilitate testing, but it's not that common and this seems like a considerably deeper intrusion.

I'd like to give some additional consideration to how me might solve this concurrency challenge without compromising the instrumentation code.

Comment on lines +102 to +106
if (testOpenTelemetry != null) {
return testOpenTelemetry;
} else {
return openTelemetryInstance;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: always prefer uninverting the if and omit the redundant else.

@surbhiia
Copy link
Contributor Author

surbhiia commented Jul 29, 2024

I'm struggling with this. I think it's a pretty strong antipattern to mix test code explicitly into the production code, which includes HttpUrlConnectionSingletons. I know we sometimes expand visibility to facilitate testing, but it's not that common and this seems like a considerably deeper intrusion.

I'd like to give some additional consideration to how me might solve this concurrency challenge without compromising the instrumentation code.

It is an interesting problem! I will also look into other ways of solving it in a cleaner way. :)

@surbhiia
Copy link
Contributor Author

Closing this PR as per our discussion in Android Sig today morning.

One possible approach we discussed we could look at for future is - Using roboelectric to test most of the functionality without BCI (as BCI might not be possible with it) and having 1 androidTest to test that BCI works (end-to-end integration).

For now, we will have 6 androidTests for httpurlconnection that can be run synchronously.

@surbhiia surbhiia closed this Jul 30, 2024
@surbhiia surbhiia deleted the develop/HttpURLConnection-androidTestsUpdate branch November 12, 2024 22:20
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.

2 participants