Testing Microservices
with REST Assured
KUSHAN AMARASIRI
MOBILE 0768027773
What is Web Services ?
• IA web service is a function that can be accessed by other programs
over the web (Http)
• Example: I can go to maps.google.com, and type in my home
address, and see a map of where I live in my browser.
REST vs SOAP
• REST allows a greater variety of data formats, whereas SOAP only
allows XML.
• REST is generally faster and uses less bandwidth.
• REST is simple to handle than SOAP.
• REST more secure as compared to SOAP as it can be integrated with
any security protocol.
• REST is very restrictive than SOAP.
• REST runs on HTTP where SOAP runs on XML
How we do testing Web Services
• Read theWDSL file obtain information such as End Point, Parameters
and Expected Response.
• Use tools such as SOAP UI, ReadyAPI, SOAP Sonar, Fiddler or POST
MAN
• Send requests with different parameters and checks for response.
• Should do positive as well as exploratory (negative) test onWeb
Services.
Test Automation of Web Services
• Web Service testing should be automated if its viable.
• There are different tool sets to automateWeb Services test
Micro services Test Automation
What is a Microservice ?
Micro Services is also a form of a Service Oriented Architecture which now talk of the town.
In a Micro Services Architecture (MCA) there are many autonomous service components,
which are called processors that communicate each other via an HTTP channel.This is also
called inter process communication.
These services are;
· Developed in different programming languages and uses different databases
· They can be easily added/replaced or removed within the architecture
· They can be easily plugged to user interfaces
· They can have different context, autonomously developed and integrated
independently
These services architecture helps continues delivery as easily each individual micro service
component can be added to the architecture without interrupting the existing functionality
and interconnections.
· Allows and achieves benefits of scalability
Types of Microservices Testing
UnitTesting –This is to test internal working of individual
Micro Services test unit.These can be automated at each
programming level using automated unit testing framework.
ContractTesting –This is to test that each Micro Services unit
adheres to the given functionalities provided in the contract
established. Here each service component is tested
individually as a black box.
IntegrationTesting –This checks that more than one service
communicates each other and provides the desired results
given in the service functional level document.
UI FunctionalTesting –This where services are integrated with a UI
and testing is done via a UI where inputs needed by the Micro
Services are given via the UI and desired output is also tested via a
UI.
Internet of Things Automation
IOT Usage
How to test IOT?
Test the Web Service the IOT device communicates. Create automation test scripts that will test the
functionality of the IOT application
Jump Start REST Assured
Jump start REST Assured
• Create a Maven Project in your Eclipse and add the following
dependency.
• Do a Clean and Install
Jump start REST Assured
• Import for the following libraries
• Create a method in the and use theTestNG library
Jump Start Karate
Jump start Karate
• It’s an Open SourceTool
• Can be integrated to Java as a Maven Project
• Write simple BDD based scenarios
• Most less coding needed
• Anyone can start automation with Karate
Jump start Karate
• Create a Maven Project in your Eclipse and add the following
dependency.
• Do a Clean and Install
Jump start Karate
• Write the following feature file
• Create the following Junit test runner file

Testing microservices with rest assured

  • 1.
    Testing Microservices with RESTAssured KUSHAN AMARASIRI MOBILE 0768027773
  • 2.
    What is WebServices ? • IA web service is a function that can be accessed by other programs over the web (Http) • Example: I can go to maps.google.com, and type in my home address, and see a map of where I live in my browser.
  • 3.
    REST vs SOAP •REST allows a greater variety of data formats, whereas SOAP only allows XML. • REST is generally faster and uses less bandwidth. • REST is simple to handle than SOAP. • REST more secure as compared to SOAP as it can be integrated with any security protocol. • REST is very restrictive than SOAP. • REST runs on HTTP where SOAP runs on XML
  • 5.
    How we dotesting Web Services • Read theWDSL file obtain information such as End Point, Parameters and Expected Response. • Use tools such as SOAP UI, ReadyAPI, SOAP Sonar, Fiddler or POST MAN • Send requests with different parameters and checks for response. • Should do positive as well as exploratory (negative) test onWeb Services.
  • 6.
    Test Automation ofWeb Services • Web Service testing should be automated if its viable. • There are different tool sets to automateWeb Services test
  • 7.
  • 8.
    What is aMicroservice ? Micro Services is also a form of a Service Oriented Architecture which now talk of the town. In a Micro Services Architecture (MCA) there are many autonomous service components, which are called processors that communicate each other via an HTTP channel.This is also called inter process communication. These services are; · Developed in different programming languages and uses different databases · They can be easily added/replaced or removed within the architecture · They can be easily plugged to user interfaces · They can have different context, autonomously developed and integrated independently These services architecture helps continues delivery as easily each individual micro service component can be added to the architecture without interrupting the existing functionality and interconnections. · Allows and achieves benefits of scalability
  • 10.
    Types of MicroservicesTesting UnitTesting –This is to test internal working of individual Micro Services test unit.These can be automated at each programming level using automated unit testing framework. ContractTesting –This is to test that each Micro Services unit adheres to the given functionalities provided in the contract established. Here each service component is tested individually as a black box. IntegrationTesting –This checks that more than one service communicates each other and provides the desired results given in the service functional level document. UI FunctionalTesting –This where services are integrated with a UI and testing is done via a UI where inputs needed by the Micro Services are given via the UI and desired output is also tested via a UI.
  • 11.
  • 13.
  • 14.
    How to testIOT? Test the Web Service the IOT device communicates. Create automation test scripts that will test the functionality of the IOT application
  • 15.
  • 16.
    Jump start RESTAssured • Create a Maven Project in your Eclipse and add the following dependency. • Do a Clean and Install
  • 17.
    Jump start RESTAssured • Import for the following libraries • Create a method in the and use theTestNG library
  • 18.
  • 19.
    Jump start Karate •It’s an Open SourceTool • Can be integrated to Java as a Maven Project • Write simple BDD based scenarios • Most less coding needed • Anyone can start automation with Karate
  • 20.
    Jump start Karate •Create a Maven Project in your Eclipse and add the following dependency. • Do a Clean and Install
  • 21.
    Jump start Karate •Write the following feature file • Create the following Junit test runner file