Has anyone had problems with parallel tests and `M...
# squarelibraries
j
Has anyone had problems with parallel tests and
MockWebServer
?
y
I'm pretty sure, it's more tests being flaky when run in parallel, rather than a direct interaction.
OkHttp's own tests have a OkHttpClientTestRule, and also a MockWebServerRule, which should do the right thing (there is a bug with junit5).
Couterintuitively a big part of the OkHttpClientTestRule is to actually reuse clients, because creating an OkHttpClient with SSLSocketFactory is expensive, and best done less often and pooled in tests.
j
Should I use that OkHttp rule?
y
I don't think we publish it for external use.
To be clear mockwebserver isn't as actively maintained as the rest of OkHttp. I don't want to suggest any extensive changes for you because it may not solve your test flakes problem.
j
No problem, I can try with Retrofit Mock as they are tests for a Retrofit adapter
👍🏻 1