Add test utility class for getting RecordedRequests from an OkHttp MockWebServer #492
Labels
new feature
A new feature such as a new class, method, package, group of classes, etc.
Milestone
The test utilities should (initially) provide a way to:
RecordedRequest
, or throw anIllegalStateException
without blocking indefinitely like theMockWebServer#takeRequest()
method doesRecordedRequest
or return an emptyOptional
if one is not availableRecordedRequest
or returnnull
if one is not availableRecordedRequest
available (using AssertJ assertions)None of these should make you catch
InterruptedException
like theMockWebServer#takeRequest
methods do. Instead, wrap with an unchecked exception or catch and returnnull
,Optional.empty()
, throw an exception, etc. Since these are test utilities, ignoringInterruptedException
isn't a big deal.Maybe also provide a few methods with specific timeouts like I did in MockWebServerExtensions.kt, for example
takeRequestWith1SecTimeout
.Also consider adding similar methods to the
urlWithoutTrailingSlashAsString
methods inMockWebServerExtensions.kt
. We can't make them extensions as in Kotlin, but they're still useful.The text was updated successfully, but these errors were encountered: