Tags API and Mashup Blog - Posts tagged with "tdd_testdrivendevelopment_ruby_webapi_api"
Tags
affliate marketing analytics announcement API Apigee API management API Proxy API Tips case study cloud API collaborative consumer debugging Design developers development example facebook features feed fixes flickr howto iPhone ipnone latency login mashup monetization monitoring notfications performance proxy response time setup sharing twitter UI vision web APIArchives
API technology (1)
Apigee how-to (3)
Announcements (4)
HowTo (1)
Screencast (1)
Thoughts (2)
Subscribe to This Blog
Test Driven Development with Web APIs
About about 1 month ago - by brian | posted in:
|
tagged with:
tdd, testdrivendevelopment, ruby, webapi, api
Often when automating test driven development we don't take the time to create a solid log of what is happening in each test. This is especially troublesome for tests that involve live connections to web APIs.
Development teams can use a free Apigee web API proxy to help give visibility into those tests that fail.
Here is an example of what is needed to use Apigee in a test driven development environment. In this case we use Ruby, but the concepts are applicable to any language.
- Setup a new proxy (or multiple proxies) at Apigee

- Setup your test initialization code to use the Apigee proxy URL
require 'test/unit'
require 'uri'
require 'open-uri'
require 'rubygems'
require 'json'
require 'active_support'
require 'htmlentities'
require 'twitter_search'
class TwitterApiTest < Test::Unit::TestCase
SEARCH_URL = 'http://twitter-growl-unit-test.apigee.com'
TwitterSearch::Client::TWITTER_SEARCH_API_URL = "#{SEARCH_URL}/search.json"
def test_twitter_search_api
q = '@apigee'
@search_tweets_client = TwitterSearch::Client.new 'Twitter Growl'
@search_tweets_client.query(:q => q).each do |r|
assert r.text.include?(q)
end
end
end - Run your tests

- use Apigee to better understand how your tests are using web APIs when they succeed and debug things when tests fail

As Apigee evolves we will provide more granular views of each request. In the meantime, happy testing.