Skip to content

Instantly share code, notes, and snippets.

@Farhandroid
Last active February 21, 2022 12:13
Show Gist options
  • Save Farhandroid/318c4e509f73dc0fbaf2cbc63a7a8c48 to your computer and use it in GitHub Desktop.
Save Farhandroid/318c4e509f73dc0fbaf2cbc63a7a8c48 to your computer and use it in GitHub Desktop.
FirstUnitTest
@Test
fun getSearchedResult_sentRequest_receivedExpected() {
runBlocking {
// Prepare fake response
enqueueMockResponse("ImageResponse.json")
//Send Request to the MockServer
val responseBody = service.getSearchedImage("nature", 5).body()
//Request received by the mock server
val request = server.takeRequest()
assertThat(responseBody).isNotNull()
assertThat(request.path).isEqualTo("/v1/search?query=nature&per_page=5")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment