Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mock backend interaction when running calabash tests

I'm in the phase of integrating cucumber tests for an existing application. The app interacts heavily with a backend. The simplest case being the registration of an user.

In order to make the tests repeatable, I cannot go against the (real) backend (for several reasons, one not being able to register two users with the same e-mail).

I'd like to know which options do I have to mock the backend behavior and deliver mocked responses. For unit testing I know Nocilla and several other frameworks. Integrating them of course does not work for calabash tests.

One alternative would be to have a real server running which I'd control from the calabash tests to control the networking. But that seems a bit overkill. Another option would be to have mock objects in the calabash target which I could control via the calabash backdoor mechanism.

I doubt that aren't the only options. So my question is: is there a more elegant way to do so?

like image 343
mAu Avatar asked Oct 22 '13 16:10

mAu


1 Answers

As I received no other feedback until today, I'll answer my own question.

We opted for the way of creating a very simple mock for our backend. We used Sinatra, but a node.js or similar technique would have led to the same result. The mock can be controlled via a simple REST API.

In the step definitions we configure our mock backend appropriately for the running scenario. It's a bit of overhead, because the mock has to evolve with the real backend, but until today it feels like a robust solution.

like image 190
mAu Avatar answered Nov 09 '22 17:11

mAu