Automating the Webservice Testing - web-services

I am completely new to webservice testing.
I want to Automate the whole webservice testing part using a framework.
For eg : i have been given with a webservice say "10.0.0.191:8082/test/login" and now i want to test its input and output result and validate it BUT with developing an automation script which does it for me.
Say, like Selenium or cucumber which automates the complete website. theres this Run button which starts the automation test and at the end gives me the report.
I want to develop something like this and i have no idea which framework is used and how to approach it.
Please help and Sincere Thanks in advance for your replies.

You need to create a webservice client and test the responses. The framework is little complicated as it will require you to know about the webservices.

We use RestTest (author)
https://github.com/rawoke083/RestTest
Just dump all your service endpoint in a file with test conditions
#my.api.tests.txt
#http-method | endpoint | expected http return code | *optional text in response body
#example to test for 200 code and text "user-ok" in response with HTTP-GET
get|http://api.example.com/user?id=123|200|user-ok

Related

Automation test for SOAP services?

In our architecture we have mule application with a list of webservices, we use jenkins for continuos integration/deployment.
No automation test at all at the moment, only few unit tests.
I was thinking to add a step after each deploy to test all webservices, something like:
input: url and request body
output: check the response code, than the response body
my questions are:
Should I use a framework to integrate in our code?
Is a simple file with the list of the webservices and a file for each
response/request a good idea to do that?
which tool do you advise me?soapui?Can I do everything I need with the free version one?
should the test be ran after each deploy?
Any advise or thoughts on that?
UPDATE:
at the moment I created a file in the sourcecode with the list of all endpoints. We are integrating it in jenkins after every deploy. We only check the return code 200 for now.
Thanks

want to test webservice with batch run

I am newbie to webservice testing with Soap UI. I've done with my testing in Soap UI. It followed with giving dynamic input parameter to the request, dynamic header and value, dynamic end point url and some property transfers. Now i want to do the same testing with out using saop ui tool. I want to go with batch script (or any other) running. Is there any way to accomplish this? Thanks in Advance !
SoapUI provides testrunner.bat that can be used to run the tests of a SoapUI project. It is located in the bin folder of the SoapUI installation.

RESTful Web Service In Grails

I made an OCR service using Grails and everything is working very well. I want to make a Web Service for it. The input of the RESTfull WS should be in mime format (the client will send some images and related information in XML format to this WS). How could I implement this in Grails? Any Sample codes to guide me?
Thanks,
Reza
These days, most people do by writing one or more controllers that accept and return text/json (or text/xml if you really want).
Grails has great libraries on board for parsing these requests, all of which are part of the Groovy language:
JsonSlurper
XmlSlurper
JsonBuilder
MarkupBuilder (for making xml)
I have used the approach above successfully on a project. You will end up with Controllers that are easy to unit test, which is a huge productivity win.

BDD when testing a web service / API

I am still trying to totally understand BDD and I am facing some doubts.
From my little experience, I have been using it to automate user acceptance test and I would like to know if it's possible to use it to test a web API, without UI.
In the past I've used BDD using the given-when-then jargon and mapping the steps to UI interactions. I've done this with Specflow in ASP.NET or cucumber/capybara in ruby on rails.
So for example we could have scenarios like this:
Given I am in the home page
When I click login button
Then I should see the login page
The current project I am working at is different. We are implementing an API based in web service which would be consumed by different type of clients. Like an iphone app, android app and an asp based web client. So our main focus is based in the back-end and just that.
In this case, the tests can't be faced from the UI point of view. So our end-to-end tests are based in our service endpoints. We pass some input arguments to a service calls and check the outputs.
Can we do this using BDD? Is this right?
or maybe it would be better to use a different thing like FitNesse?
Hmm.. is using FitNesse doing BDD?
I think you can do what your writing about in BDD. I'm not sure if those 2 links about testing of webservices with SpecFlow will help you but take a look on them if you haven't seen it yet.
http://codedetective.blogspot.co.uk/2012/10/testing-webservices-with-specflow.html
http://www.creamdog.se/blog/2011/02/24/webservices-automated-tests-using-specflow-and-babelfish/
Have a look at Karate, web service testing framework by Intuit. It's recently being open sourced. It has the capability of handling API dealing with HTML, JSON, XML, GraphQL queries and is built on top on cucumber.
Simple intro here : https://medium.com/blueprint-by-intuit/karate-web-services-testing-made-simple-366e8eb5adc0#.qnpy5gagt

Selenium - can it test a B2B web service

I've used Selenium to do lots of UI testing from the browser. If you have a web service behind the Java jsp page i.e. in a servlet, you can test it from Selenium.
Can Selenium be used to test a B2B web service i.e. a web service called from a backend that has no browser UI component?
I have used SOAPUI to do this kind of testing in the past but our test department is trying to standardise on Selenium.
You can but I would not recommend it. If the page is returning XML, you won't be able to use the standard Selenium calls to verify what is happening as you won't have access to the DOM. If its returning plain text for JavaScript then you will struggle with verifying the output.
This is a definite case of using the right tool for the job and Selenium is not the right tool for testing web services. I would use soapUI or just use some http library to call the service URL and then verify the results.
If they are looking to standardise they need to standardise tools for their purpose. Selenium for UI, soapUI for webservices,XUnit Framework for unit and integration.
You can, but it's really not the right tool for the job. It's like trying to hammer a nail into a piece of wood using a stapler instead of a hammer.
That said, probably the most appropriate way to create a page with all your input parameters which could do the call for you and echo the results back into a html element. If the service is meant for AJAX calls then this is probably the ideal solution for your service.
The correct approach would be to use a unit testing framework and create a test harness which you can push your parameters into, execute the service call and retrieve the results in a meaningful way for assertion.