0

I am using Retrofit on Android to send a large file to a service, using a series of PUT requests. The code works (or appears to!), and now I want to add some unit tests. The file transmission is split into chunks and sent in multiple requests. I want my tests to capture the request body data and accumulate it all, then at the end I will verify the concatenated data chunks sent exactly matches the test file. This is to verify there are no off-by-one chunk boundary errors or overlaps and that kind of thing.

I have read about the Retrofit MockWebServer but in this case I don't care about mocking/processing the server response -- I only care about the request.

I know I can roll my own by adding an Interceptor to the OkHttpClient instance that Retrofit uses and doing the gathering/buffering myself, but it seems the kind of thing that people must have done before and I wondered if there is perhaps a different Mock server that supports this directly?

(Just to be super clear, I'm talking specifically about the request, not the response.)

Ben
  • 1,881
  • 17
  • 20

1 Answers1

1

See examples like https://stackoverflow.com/a/38525843/1542667

which use MockWebServer just as a way to access RecordedRequest

Yuri Schimke
  • 12,435
  • 3
  • 35
  • 69