Philip Schweiger wrote:
> I've been trying to make unit-testing a more regular part of my work
> flow - using qUnit so far. I've found it helpful for developing self-
> contained projects, for instance jQuery plug-ins. I'm struggling with
> working with third-party APIs, though. [ ... ]

> The specific case is working with Facebook.  [ ... ]

> I know sometimes the
> answer to is to mock your third-party interactions, but when working
> so closely with an API, that doesn't seem realistic or appropriate.

I'm guessing that this is still going to be your best approach.  It's
usually not terribly hard to mock out the service calls that you need,
often by recording the actual results of making such calls.  This is
more of a help in writing tests that help you avoid a regression or
test upgrades to new versions of a third-party API than it is in
performing initial development.

For initial development, your wrapper is probably a good idea: at
least you've reduced the surface area of the code that needs to be
tested against the Facebook API.  Then you probably need to determine
the states that need to be tested and what simple tests can capture
them straightforwardly.  It's still mocking, and it still can be
painful, but it may be the best option available... unless... have you
asked whether Facebook has exposed its own mock version for testers?
A popular public API might be willing to provide some sort of Mocks
for their developers.  It's not particularly likely that they have
such a thing published, but they presumably need to test their API
internally, and I wouldn't be surprised if they have their own Mock
Objects used internally.  All that would be needed is for them to
share these with developers.

  -- Scott

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to