Search code examples
unit-testingtddintegration-testingpaymentrecurly

Running tests against Recurly API alongside live site


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?


Solution

  • 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.