I know this would slow down your integration tests and complicate them, but wouldn't you want to avoid mocking twitter this way to actually test that your site is integrating properly with the service? Mocking obviously has its place, but I'd avoid it if possible for end to end testing like this.
Proper in this case: OmniAuth abstracts away the actual OAuth process and, as is always proper, you should be testing your application code not your libraries.
I have this challenge and I'm very interested in seeing how others solve this without using mocks. For my tests, I have 5 tests that rely on Twitter logins. Given that I run my tests ~10 times per day (on each commit), and other developers run my tests on their commits, I would have number_of_developers * commits_per_developer_per_day * 5 logins per day with a real twitter account. My guess is that that would run afoul of twitter's policies.
I'd love to see a web based stubbing service that would let me test against Twitter and especially Facebook without using real accounts on either.
You should mostly just ensure that the requests your software makes are correct, and that you're testing response handling with correct responses; what actually happens at the other end is of no concern to you.
At some point, of course, you may want to run actual integration (preferably against test users/whatever) but that needn't be a part of your regular test suite, so you can for example add an env toggle to actually perform remote connections, or have a separate normally-excluded set of tests for that.
Comments
I know this would slow down your integration tests and complicate them, but wouldn't you want to avoid mocking twitter this way to actually test that your site is integrating properly with the service? Mocking obviously has its place, but I'd avoid it if possible for end to end testing like this.
Proper in this case: OmniAuth abstracts away the actual OAuth process and, as is always proper, you should be testing your application code not your libraries.
I have this challenge and I'm very interested in seeing how others solve this without using mocks. For my tests, I have 5 tests that rely on Twitter logins. Given that I run my tests ~10 times per day (on each commit), and other developers run my tests on their commits, I would have number_of_developers * commits_per_developer_per_day * 5 logins per day with a real twitter account. My guess is that that would run afoul of twitter's policies.
I'd love to see a web based stubbing service that would let me test against Twitter and especially Facebook without using real accounts on either.
Facebook does offer test user accounts (with an api) exactly for these types of scenarios http://developers.facebook.com/docs/test_users
I don't know if twitter offers anything similar.
I didn't know about these Facebook test accounts. Thanks for letting me know. These will be very helpful.
You should mostly just ensure that the requests your software makes are correct, and that you're testing response handling with correct responses; what actually happens at the other end is of no concern to you.
At some point, of course, you may want to run actual integration (preferably against test users/whatever) but that needn't be a part of your regular test suite, so you can for example add an env toggle to actually perform remote connections, or have a separate normally-excluded set of tests for that.