Testing REST webservices [closed]

2019-01-10 03:22发布

问题:

My organization is working on building RESTful webservices on JBoss appserver. The QA team is used to testing SOAP webservices so far using SoapUI. SoapUI has a new version that has REST capabilities. We're considering using that.

  1. Are there any publicly available RESTful services available on the net for free that someone could test ?
  2. What tools are available(and used) for testing RESTful web services ?

回答1:

soapUI will do the job as well, check out this blog post to get started.



回答2:

Please try Firefox addon Poster , which is simple to use and gets you up nd running quickly



回答3:

You can exercise web services using fairly trivial bits of Python. Depending on your security, you may be able to simply use Python's urllib or urllib2 to do do you REST requests and examine your answers.

Additionally, you might want to use Python unittest to control the execution of the Python tests of your REST services.

class TestSomeREST( unittest.TestCase ):
    def setUp(self):
        REALM = "blah@blah.com"
        self.client= RESTClient( "localhost", 18000, "tester", "tester", REALM )
    def test_1_get(self):
        response = self.client.get('/this/that/other/2/')
        self.failUnlessEqual(200, response.status_code)
        j1= JSONDecoder().decode(response.content)
        self.assertEquals(2, j1[0]['pk'] )
        entity= j1[0]['fields']
        self.assertEquals('Some Other Group', entity['name'])
        self.assertEquals('E1G2', entity['customer_id'])

The RESTClient class uses urllib2 to pass through digest authentication for each request. It's rather complex, but I can share the essence if it's of interest.



回答4:

Check out Fiddler



回答5:

CURL Gets you halfway there. The other half is checking the headers, response codes and entity content to make sure its good. You could use a variety of tools for that (in shell scripting land, piping the header and contents to files, and diffing them might just do the trick). It wouldn't be that difficult to further refine the toolset, maybe stacking curl up with the unit-testing framework of your choice.

I built a rest webservice testing panel with AJAX. It wasn't that difficult at all actually. You have some security issues to work out (i.e. making sure that you have the test suite on the same server, or maybe signed Javascript.)



回答6:

To test a REST service you can try REST Assured which makes it very simple to test REST services and validating the response in Java (using JUnit or TestNG).



回答7:

Check out Postman - https://chrome.google.com/webstore/detail/fdmmgilgnpjigdojojpjoooidkmcomcm/. This is a tool I have been working on over the past several months and lately from the feedback that I have been getting it's becoming quite useful for large REST projects while helping with basic REST endpoint testing.

The code for this is available on Github as well. https://github.com/a85/POSTMan-Chrome-Extension



回答8:

The simplest way to test REST web service is using curl in terminal.

There are some codes I used to test my web service of rails. You may modify them to fit your services.

GET

curl http://localhost:3000/courses.json

POST

curl -H "Content-Type:application/json"  -d '{"courseCode":"55555","courseName":"SEEEE","courseYr":999}' http://localhost:3000/courses.json

PUT in Raills: eg1(with all fields) :

curl -H "X-Http-Method-Override: put" -H "Content-Type:application/json"  -d '{"courseCode":"123456","courseName":"AAAAAAAA","courseYr":12345}' http://localhost:3000/courses/5.json

eg2(with the field only be edited) :

curl -H "X-Http-Method-Override: put" -H "Content-Type:application/json"  -d '{"courseYr":999999999}' http://localhost:3000/courses/3.json

DELETE in rails with id provided

 curl -H "X-Http-Method-Override: delete" -H "Content-Type:application/json"  -d '{"id":4}' http://localhost:3000/courses/5.json


回答9:

I don't have tested it yet but this Java app seems to be nice to test REST services. There is also a tutorial on Javalobby about it.

Java App: http://code.google.com/p/rest-client/

Tuto: http://java.dzone.com/announcements/wiztoolsorg-restclient-21-rele



回答10:

you can use the Simple REST Client is an extension for Google Chrome too https://chrome.google.com/webstore/detail/fhjcajmcbmldlhcimfajhfbgofnpcjmb



回答11:

SOA Cleaner, is a test tool that tests both soap and rest (also WCF, but it seems you don't need that feature). It's very intuative, and usable. Written in .NET. A free version is also available. can be downloaded from http://xyrow.com. Good luck!



回答12:

I'm testing RESTful services with an in house .NET framework (no problem porting it in Java). Basic principles:

  • build client (to make the calls)
  • build type classes (XML and JSON)
  • deserialize response
  • assert stuff

If you want more info, I'm glad to talk.



回答13:

I'm using REST console extension for Google Chrome and It's by far the best i've tried. It also supports various security mechanisms like OAuth

(update 2: fix link)



回答14:

For java, there also exists RESTFuse, which allows to develop unit tests which may look like this:

@Rule
public Destination destination = new Destination("http://localhost:8080/rest/");


@HttpTest( method = Method.GET, path = "/status" ,authentications =
   @Authentication(type = AuthenticationType.BASIC, user = "joe", password = "doe")
)
public void testAuthRhqadmin() {
    com.eclipsesource.restfuse.Assert.assertOk(response);
}

This test runs against http://localhost:8080/rest/status and authenticates as user joe with password doe. The body of the method then checks that the GET call returns a 200 status code.



回答15:

Try Python's httplib. It's very easy, you specify the method, url, and use urllib.urlencode for the parameters/POST body.

This can be combined with the builtin unittest module if you like, for reporting of errors.



回答16:

I've been using JMeter for this, especially for stuff like load testing. It's similar to SoapUI (which I've also used), but geared more toward testing web pages, which makes it pretty decent at testing RESTful services, too.



回答17:

I've written a program specifically for testing REST Web Services. Its a pretty simple application written in .NET 2.0 (I've only tested it on Windows Vista, but should work on XP also). The application uses HttpWebRequest to make requests, and displays the resulting response, as well as the headers for the request and response. I've done a bit of testing, but I thought it might help you test your web services.

REST Test



回答18:

I'm currently investigating wsclient CLI app for this purpose (http://wso2.org/library/3362). It is quite promising, and can be used to hack a quick test from a bash shell. Of course, as many mentioned here, many of the tools that come with a *nix system will do the job with a tidbit of coding/scripting



回答19:

If you like using Ruby there's a REST-Client gem for it

For testers I find ruby is a really easy language to learn, and it has some excecllent tools like Cucumber for doing BDD style acceptance tests.



回答20:

I've tried numerous REST clients and by far the best I've used is the Chrome app: DHC.

DHC (aka Dev HTTP Client) is designed and developed by a developer for developers to make direct HTTP resource discovery, manipulation and testing more easily. Beside the main function, sending/receiving custom HTTP requests/responses, it allows permanently to save a request to a local repository for later reuse and moreover the request declaration can include variables that are context specific. With the use of contexts you can easily switch between various environments without modifying request declaration. (e.g. from a test environment to production)



回答21:

Testing REST full web services is a easy task to do. Free ad-ons are available on the browsers as REST Client from where you have to send a web service with expected/required method type: GET/POST/PUT/DELETE If the parameters are matched then output will get generated in the body of browser.



回答22:

I know it is very old question, but could be helpful to others. Just to answer your first question you can check here to get some REST webservices to test.

Fiddler and Poster plug in Firefox can be use to test any REST web services. SoapUI also comes with RESTful webservices support.



回答23:

For advanced REST testing you can try HttpMaster.
It supports dynamic parameters, friendly viewers for XML/JSON, and various types of response data validations that can be combined into logical expressions.
For basic http requests some browser plugin will be sufficient.



回答24:

OnionTest still beta , but quite useful