If I could not reorganize the method signature (perhaps this method really only needs one value from HttpResponse?), I would have Eclipse generate a zero implementation of HttpResponse (yes, I am in Java, but this is the idea) - that is, it implements everything methods that return zero - and just fill in only those that I need in the test method, and return some constant values ββto them. (Yes, I could use some kind of mocking structure.)
The reason you cannot create your own instance of an existing implementation will be very tied to your application server, and you probably need every other nut to even create an instance.
If this turned out to be, I need something more complicated than a simple zero version of HttpResponse, then I would look at NOT testing this method directly: perhaps a test of one or two levels will be simpler and will provide me with the same level of confidence in the code.
Rodney gitzel
source share