Hi Chris,
I would recommend Cucumber, since you can define certain steps in Ruby, and
let your QA folks write plain english tests that match those steps
(features, in Cukes speak).
Let's say you want to hit a Java App with curl commands wrapped in a simple
Ruby lib. The lib could store cookie info temporarily to pass into the next
commands after a successful login, for instance. So you could login as an
admin with it, then create a new user using your admin credentials.
You can have the steps perform any actions you like, so you could do
something like:
create_user.feature
=======================
Feature: Create User
In order to allow my customers to login from different regions
As an admin
I want to create regional users
Scenario Outline: Create user with a region
Given I have logged in as an admin
When I create a user with name <name> and region <region_id>
Then I should get back the new user's attributes
And the user should be assigned to region <region_name>
Examples:
| name | region_id | region_name |
| Adam | 30 | US |
| Yoshii | 31 | Japan |
So lets say you wrapped your java api curl commands in a ruby lib called
JavaApp::Api...
step_definitions.rb:
=========================
# encoding: utf-8
begin require 'rspec/expectations'; rescue LoadError; require
'spec/expectations'; end
require 'cucumber/formatter/unicode'
$:.unshift(File.dirname(__FILE__) + '/../lib')
require 'java_app/api'
Before do
@api = JavaApp::Api.new # <== Here's where you instantiate your Api
class instance that does the CURL'ing
end
After do
end
Given /I have logged in as an (.*)/ do |name|
@api.login(name)
end
When /I create a user with name (\w+) and region (\d+)/ do |name, region_id*|*
@user = @api.create_user(name, region_id)
end
Then /I should get back the new user's attributes/ do
@user.has_key?(:id)
@user.has_key?(:name)
end
And /the user should be assigned to region (.*)/ do |region_name|
@user.region*_name.*should == region_name
end
Something like that.
Good luck!
- Adam
On Thu, Oct 4, 2012 at 10:35 AM, Chris McCann <[email protected]> wrote:
> In my day job I work on a large Java-based web app that uses a RESTful
> JSON API to serve data to a JS-based front-end. Our QA folks are
> struggling a bit with how best to do automated testing of the API.
>
> I've done some googling but come up empty-handed. Can anyone recommend a
> solid integration testing framework that uses declarative (think "shoulda")
> language for describing tests that we could use to exercise the API?
>
> Thanks,
>
> Chris
>
> --
> SD Ruby mailing list
> [email protected]
> http://groups.google.com/group/sdruby
--
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby