2

I have an interactive CLI app based on Highline gem. I can run it interactively for Cucumber tests using Aruba. But I can't using stubs and mocks, because Aruba starts my app as a child process. If I try to use Aruba::InProcess feature, it loses interactivity.

I have no idea any more. In what way can I testing such app?

Michael
  • 135
  • 2
  • 11

2 Answers2

0

What exactly do you want to stub and mock?

Cucumber is primarily used for integration testing, i.e. testing from end-user's point of view. End-users use the app through its interface, that's why cucumber does not provide easy ways of stubbing and mocking the app's internals and you should not do it either, at least not with cucumber.

Consider using fixtures for cucumber or unit testing with rspec.

If you want to stub out responses from 3rd parties, then you can use webmock gem to intercept requests and return fixtures as a response or fakefs to do the same for the filesystem.

Yaro
  • 148
  • 8
  • I want to stubbing interaction with remote platforms API or with file system, for example. It is a long time between user action and result returning because remote API interaction. These tests will be not usable with that. – Michael Oct 19 '14 at 06:59
  • Webmock and fakefs cannot be used because of interactivity issues described in my a question. – Michael Oct 28 '14 at 07:44
0

Ok, I take that: Cucumber is not about stubs and mocks. And interactive CLI apps is, probably, the best example for it. So, while you need interactivity, Cucumber through Aruba starts your app in a child process. And the only way for affect it, I find, is environment variables usage. For example, by setting variable with values 'production'/'development'/'test' I can change configuration of my app to using test DB instead of production etc.

Michael
  • 135
  • 2
  • 11