2

I have a bit of a problem. I'm trying to develop against the Recurly API, but I can't seem to find any way to use test accounts or a test gateway alongside a live and running Recurly account.

It seems that they only way I could do it would be to break our site while I run the tests. It seems unlikely that it would be that badly designed, but I can't find a way of doing it. Does anyone else have a solution?

Tom Busby
  • 1,319
  • 2
  • 12
  • 25

3 Answers3

4

What we typically recommend is creating a second site that's just for development and testing. Then as @atif suggested you can use a separate API key for tests and development without worrying about affecting your production site. One downside to this approach is you'll need to re-create any plans and coupons you're using in your testing.

You'll probably want different levels of testing. You'll want a few tests that actually integrate against our servers, create accounts, make a subscription etc that you run infrequently because they'll be slower. For most of your tests I'd try to follow @ryan1234's advice and use stub/mock/fixtures for the remote requests. It'll make for much faster tests.

drewish
  • 9,042
  • 9
  • 38
  • 51
  • How does one set up a second subdomain for this purpose? I can't find anything in the Web UI to allow me to do this with my existing profile. – colan Jun 09 '16 at 18:09
  • Most people just sign up for a second site and stick a -dev or -test suffix on it. – drewish Jun 10 '16 at 15:58
  • 1
    Makes sense. To have both sites in your profile, it looks like you need to log out, sign up with a different e-mail address, and then add your original e-mail address as a manager. – colan Jun 13 '16 at 13:36
2

I would create an interface between your code and Recurly API calls.

So the logic would go:

Application code -> Interface -> Recurly API call.

Then the steps to test would be something like this:

  1. Make one or two safe real HTTP calls to Recurly.
  2. Log the HTTP request output of (1) into a file/string.
  3. Replace the live implementation of your interface with a dummy interface.
  4. Have the dummy interface compare the data from (2) with the data generated when you run a test.
  5. If the data through the dummy interface matches what you expect, then you're good!

The key point is that true integration testing might not be possible, but it is possible to test that you're generating the right requests on your side.

Then as long as their API stays the same, you can test quickly and accurately without going over the wire.

ryan1234
  • 7,237
  • 6
  • 25
  • 36
0

update just he recurly helper file if you have in your app ,use developement api key of reculy on production when you are testing ,when you want to site to work as a live site then again update to production environment respectively.

atif
  • 9
  • 1