views:

66

answers:

3

Say there are multiple requests in a integration test, some of them are local sphinx calls(locator for example).

Should we just stub out the entire response of these sphinx call, or, since it is a integration test, we want to excise the entire test without stubbing. If that is the case, how do we still keep test independent in the situation when sphinx fails, no internet connection, or third party server non-responsive.

Give reasons.

Thanks

+2  A: 

I think you answered your own question. If you want to be isolated from your "sphinx" thing (I assume it is some boundary) you are better off mocking it and run everything else as it would normally run, as an integration test. That way, as you yourself said, you can test connection loss and other unexpected situations.

Otávio Décio
A: 

If your problem with sphinx is that it is running somewhere else. possibly on the Internet and it's not under your control, you might consider using fakeweb. It allows you to catch requests that go to the Internet and respond with predefined answers. If your sphinx server is somewhere else, you can just catch your systems request and give it the response you want for your test. This way you don't need to write a mock and still can use (and test) the same piece of code that would usually send the request.

If this might be useful in your case, just take a look at the official page. For me this made so many things much easier.

ajmurmann
A: 

I would typically write two level of tests one unit test which stubs out the expensive method calls. And another one which is an integration test.

Calm Storm