7

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?

mAu
  • 2,020
  • 1
  • 14
  • 27
  • You can try auto generated user emails with a known prefix to register new users. And whenever you need you can search with that prefix and delete all from the server at once. – Chathura Palihakkara Jan 03 '14 at 06:22
  • It's not only about the e-mails but about every backend interaction that depends on a certain state. But right now we went with a small Sinatra server whose responses can be configured by sending PUT requests from within the calabash step definitions. – mAu Jan 07 '14 at 07:53

1 Answers1

3

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.

mAu
  • 2,020
  • 1
  • 14
  • 27
  • 3
    Could you please go a little further into how you did this? Did you modify the base URL your app was pointing toward for your test target? Did you use some kind of proxy to redirect the traffic? I am absolutely tearing my hair out trying to figure this stuff out. – s73v3r Sep 10 '14 at 18:25