views:

82

answers:

1

What are good practices of unit testing facebook Canvas applications ?

Lets say you have MVC application with controllers utilizing local Facebook library which provides access to Graph API, FB session. After all your application depends on facebook authentication mechanism (OAuth and Facebook Connect) thus user is required to authenticate before proceeding.. How would you go with unit tests for controllers ? One thing comes to my mind - having a Facebook library with 'testing' mode and fake session might do the job. Any ideas are appreciated.

+1  A: 

When I had this problem, I just wrapped the Facebook library calls in an object (or a set of functions functions), and used a mock of that object in the unit tests.

Gintautas Miliauskas
Right, thanks for your answer. That's exactly what I was thinking about, but the thing is that most of facebook components of this application depend on the data they receive from Graph API calls so it'd be great to test this logic as well.. I'd better ask a rather technical question is it possible to get OAuth 2.0 access token statically (for instance with a fake cookie) ? PS: I am using Python Paste to test controllers..
pk4r