Automate Rest Webservice testing using jasmine node - web-services

We are having an requirement to automate REST web services testing with jasmine node. Im pretty new to web service testing and node js as well.
What exactly we need to test in web services?
Could you please also guide in order to automate REST services testing.
Thanks,
Tanmay

A REST Web Service uses http verbs (GET, POST, PUT, PATCH, DELETE) to do various actions. So to test a web-service you need to write tests that send these requests with the appropriate data for your web-service and then examine the results. There are various test frameworks that make your life simpler.
Take a look at some simple tests I wrote for a sample REST Web-Service here.
The tests I wrote were for the purpose of running in Mocha but Jasmine should not be too different. Here is a great article on Jasmine and Mocha and the differences and similarities between them.

Related

Testing google authentication using mocha and chai

So, i am a beginner in (like literally just started) unit and integration testing using mocha and chain for backend, i want to test a feature where we create new user, and the new user is created by signing-in with google. How to test the google authentication?
Earlier i thought of triggering /google/callback endpoint directly, but, turns-out, it is only supposed to get response from Google Authentication server.
So, how can i test google authentication using mocha and chai?
Please help!
Thanks in advance!

Test queries using SOAP API web service

How can I perform test queries using SOAP web service? Which tools or something I should to use? I'm newbie on this topic. I have url, password, login name and I would like to see result of queries in XML format.
As far as I know the most commonly used tool for testing web services is SOAP UI. This allows you to test just about all aspects of a soap API. From just a basic test request to complete Test Suites
SOAP UI can be found here.

TDD in Java Servlet Web Service

I already know how to write JUnit test cases (can also use Mockito). Thanks for the simple tutorials in the web for that. The only problem is that I can't find any examples on implementing it to an actual or let's say realistic project.
I have a simple REST web service which uses Servlets. It has an API method that sends a POST request to another web service then arranges the data as its response.
The API request is processed by two layers:
Servlet (Controller) - validates the request parameters
Service - The sender of the POST request to another web service
Here's what the service method does:
Prepares a parameter data (some attributes are provided in the paramaters of this request, some are retrieved from the database)
sends a request to another web service which responds with an image url for a QR Code
Decodes the QRCode image and then responds to its request with the decoded text
What are the unit tests cases needed for this?
How about integration tests? Do I have to use ServletUnit, or can I just run the server and write tests with requests to the running server?
Unit testing usually involves testing a single class in isolation. So you would need tests for the servlet class and for your service class as well.
If you're interested in unit testing a servlet, then have a look at these answers. In your case, you need to mock any external dependencies and check for example if valid parameters are sent to the service method.
Unit testing the service method includes mocking all external dependencies (web service, database) and only test the logic that's performed in the method (e.g. data is prepared correctly, QR decoding and responding with the correct text).
Most of the time you end up writing integration tests since you have multiple components which need to work together. There are multiple possible solutions to tackle that problem. You could create a separate integration testing environment which tries to replicate your production environment as closely as possible (web server, application server, database). For smaller projects that might be too much work and you could just spin up an embedded Tomcat with some kind of an in memory database (H2 for example). Keep in mind that for integration tests to be repeatable you might have to reinitialize the database for every test run.
In addition, you mentioned a web service which responds with a URL to a QR code. If you're not in control of that service, I would try to mock that service as well. You don't want to have a failing integration test because of a web service which might not be available 100% of the time.
Since your Servlet acts as a RESTful web service, take a look at rest-assured. This is a DSL for testing REST services.

Approaches for creating REST Web services?

i am new to REST Service development. I compared the development mechanism for both REST and WS web services and i found that you can create a WS web service using WSDL file that is the top down appraoch (Correct me if i am wrong) and using bottom up approach also, that is generating the classes manually.
But when it comes to REST web service development you have to follow bottom up approach only that is generating the classes manually. NetBeans IDE provides certain wizards for creating REST web service quickly from databases, entity classes and patterns.
I had also seen when you are developing web service in eclipse and you are using wizard in eclipse IDE, you can create a REST web service from WSDL file. I found this very strange. My question here is what are the approaches we can have for creating REST web services. Can we create REST web services using top-down and bottom up approached. If yes then please provide me details.
Thanks.
It is possible to describe a REST service using a contract. This is the intent of WADL and WSDL 2.0. WADL is specifically a REST contract, whereas WSDL 2.0 evolved from the original WSDL spec. to support all HTTP bindings. Since REST services rely on the use of HTTP methods and headers to exchange messages a WSDL 2.0 contract can work. There is a really good explanation here: http://ajaxonomy.com/2008/xml/web-services-part-2-wsdl-and-wadl
For development of REST services, I'm not sure if NetBeans, Eclipse or other tools specifically support automated REST service from WSDL generation. I would imagine that most are still intended for SOAP service creation. At this point I think WSDL 2.0 and WADL can be used to describe a REST service, but are not intended for automated generation of a REST service.
REST services are simple HTTP request/response,and therefore don't require complex stubs. In most cases it would probably take more time to write the WSDL describing the REST service, than it would take to write the REST service itself.

Nunit - XML based Data provider

I have used TestNG & Selenium for Test UI Automation
For .NET web services testing http web requests can be used to do functional testing
Has any one tried web services automation using Nunit ? Does it support passing data parameters in XML (Data Driven Testing) like TestNG?
Any experience/guidelines with WCF / ASPX 2.0 Web services functional test automation using Nunit if you can share would be helpful
Thanks,
Siva
I like to think about Web Services, WCF Services as another kind of interface to my business logic. And I only unit test my logic.
There is nothing specific in NUnit for testing WCF or Web Services.