zhang-pc / mockwebserver

Automatically exported from code.google.com/p/mockwebserver
Apache License 2.0
0 stars 0 forks source link

Make MockWebServer testable #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

we face a very rare situation : in one of our app, we need to embed the 
mockwebserver library inside the app itself, not in its tests. Our client wants 
an app that can be used in a "demo mode" that will return mocks of webservices 
(static json files mostly). Thus we embedded the mockwebserver inside the app 
to replay the mocks.

But we are now facing a problem : the mockwebserver can only be tested via the 
network : by sending real requests and checking if the results match expected 
json responses.

Nevertheless, it would be possible, by some minor changes in the architecture, 
to make the mockwebserver testable directly without using the network.

For us, only one of them would be interesting : being able to test a 
dispatcher. To achieve this, it would be enough to have 1) a public constructor 
for RecordedRequest or 2) make the class non final. 

Would it be possible for the mockwebserver team to provide us with a public 
constructor inside RecordedRequest so that we can create custom Requests, 
inject them in the dispatcher and test if our dispatcher returns the 
appropriate response ?

That's really an urgent need for us. If the project would have been on github 
we would have been pleased to submit a pull request for this. Without this 
change, we will have to fork mockwebserver and we would prefer not too as your 
lib is really great and we would like to keep it in sync with your great work.

Thanks in advance,
 Stéphane

Original issue reported on code.google.com by steff.ni...@gmail.com on 25 Jan 2013 at 6:27

GoogleCodeExporter commented 9 years ago
If you insist, I'll use my time machine and fix your problem 24 hours before 
you reported it.
https://code.google.com/p/mockwebserver/source/detail?r=33

Original comment by limpbizkit on 25 Jan 2013 at 1:21

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Thx ! :)

Original comment by snico...@octo.com on 21 May 2013 at 7:37