mockwebserver

Suspending function test with MockWebServer

折月煮酒 提交于 2020-12-13 03:42:49
问题 I'm testing api that returns result using suspending function with MockWebServer, but it does not work with runBlockingTest, testCoroutineDispatcher, testCorounieScope unless a launch builder is used, why? abstract class AbstractPostApiTest { internal lateinit var mockWebServer: MockWebServer private val responseAsString by lazy { getResourceAsText(RESPONSE_JSON_PATH) } @BeforeEach open fun setUp() { mockWebServer = MockWebServer() println("AbstractPostApiTest setUp() $mockWebServer") }

Suspending function test with MockWebServer

梦想的初衷 提交于 2020-12-13 03:41:30
问题 I'm testing api that returns result using suspending function with MockWebServer, but it does not work with runBlockingTest, testCoroutineDispatcher, testCorounieScope unless a launch builder is used, why? abstract class AbstractPostApiTest { internal lateinit var mockWebServer: MockWebServer private val responseAsString by lazy { getResourceAsText(RESPONSE_JSON_PATH) } @BeforeEach open fun setUp() { mockWebServer = MockWebServer() println("AbstractPostApiTest setUp() $mockWebServer") }

delay MockWebServer response

北城以北 提交于 2020-01-03 18:58:32
问题 How can I delay a Square MockWebServer HTTP response? There is a response.setBodyDelayTimeMs(...); method but this is only used in SpdySocketHandler and not for HTTP requests. 回答1: That's a bug that we OkHttp maintainers need to fix. If you report it on our issue tracker, we'll tale care of it. Or better yet, send us a pull request! 来源: https://stackoverflow.com/questions/26778379/delay-mockwebserver-response

delay MockWebServer response

孤人 提交于 2020-01-03 18:58:30
问题 How can I delay a Square MockWebServer HTTP response? There is a response.setBodyDelayTimeMs(...); method but this is only used in SpdySocketHandler and not for HTTP requests. 回答1: That's a bug that we OkHttp maintainers need to fix. If you report it on our issue tracker, we'll tale care of it. Or better yet, send us a pull request! 来源: https://stackoverflow.com/questions/26778379/delay-mockwebserver-response