OkHttp MockWebServer fails to accept connections when restarted

前端 未结 2 1764
情深已故
情深已故 2021-02-20 17:00

I\'m using the OkHttp MockWebServer to mock my server responses for unit tests.

It works great for the first test, but on the 2nd test my client fails with:

2条回答
  •  温柔的废话
    2021-02-20 17:43

    This localhost connection fails because it does not belong tot he mock server. Use this instead (mockHelper.getHost()).willReturn(okhttpMockWebServer.url("/").toString())

提交回复
热议问题