Testing Facebook Connect applications

At Hunch, we use Facebook Connect to make it easier for our users to create accounts. Knowing who a Hunch user is on Facebook also improves the recommendations on Hunch as we can look at what the user has already “liked”. Unfortunately, it’s really difficult to test Facebook Connect applications as you cannot easily create test Facebook users.

We’ve worked around this by creating a minimal re-implementation of the Facebook Graph API. So instead of making Facebook API calls to the real Facebook, we can make API calls against our fake Facebook. Our fake Facebook, called Fakebook, can simulate an unlimited number of fake Facebook users which is handy for load testing.

Fakebook is still very incomplete in terms of which parts of the Facebook Graph API it emulates, but it emulates enough to allow us to see what happens when thousands of simulated users all try to Facebook Connect into Hunch at once. Currently, all of the data Fakebook returns is random (random email addresses, random first names, random friends etc). This makes it easy to do load testing but makes it harder to do functional testing where your tests actually care about the values in the data. This is probably what we’ll work on handling next.

The Fakebook is written in Python and is designed to run on Google App Engine. You can check it out at http://code.google.com/p/thefakebook