SlideShare a Scribd company logo
1 of 80
Structured Functional Automated Web
Service Testing
Roy de Kleijn
Who am I ?
• Technical Test Consultant
• Trainer test automation
• Involved in R&D activities
• Blogs:
– http://selenium.polteq.com
– http://www.rdekleijn.nl
Agenda
1. Web Service introduction
2. What's in it for testers ?
3. Testing a Web Service
4. Cases
Agenda
1. Web Service introduction
2. What's in it for testers ?
3. Testing a Web Service
4. Cases
What is a Web Service ?
A Web service is a software component that can be
accessed by another application (such as a client, a
server or another Web service) through the use of
generally available, ubiquitous protocols and
transports, such as Hypertext Transport Protocol
(HTTP).
[Gartner]
Architecture - conventional
application
DB
Web Service Based Architecture
• Scalable
Web Service Based Architecture
• Scalable
• Support for any application type
Web Service Based Architecture
• Scalable
• Support for any application type
• Language independent
Web Service Based Architecture
• Scalable
• Support for any application type
• Language independent
• Central business logic
Web Service Based Architecture
• Scalable
• Support for any application type
• Language independent
• Central business logic
• Standardised integration
Different types
• Protocols: WSDL / SOAP / REST
Different types
• Protocols: WSDL / SOAP / REST
• REST (Representational State Transfer)
– Defined by HTTP interface
Different types
• Protocols: WSDL / SOAP / REST
• REST (Representational State Transfer)
– Defined by HTTP interface
– Support of basic application methods (CRUD):
• POST -> create new resource
• GET -> retrieve resources
• PUT -> replace existing resource
• Delete -> remove a resource
Architecture - SOA
application
Architecture - SOA
application DB
Service
1
Service
2
Service
3
Architecture - SOA
Desktop
application
Mobile
application
Third-party
application
Architecture - SOA
Desktop
application
Mobile
application
Third-party
application
DB
Service
1
Service
2
Service
3
Service
4
Third-party
How it works...
• Request messages are send to a specific endpoint
• Messages are mostly XML or JSON fragments
• Client can optionally set headers
Agenda
1. Web Service introduction
2. What's in it for testers ?
3. Testing a Web Service
4. Cases
Benefits for a tester
• Less brittle tests
– No GUI involved, no browser time-outs
Benefits for a tester
• Less brittle tests
– No GUI involved, no browser time-outs
• Testing can start in an early phase
Benefits for a tester
• Less brittle tests
– No GUI involved, no browser time-outs
• Testing can start in an early phase
• No access to the code required (might be benefitial
though)
Testing Pyramid
UI
SERVICE
UNIT
Developers
Testing Pyramid
UI
SERVICE
UNIT
Automated UI Tests
Automated API Tests
Automated Unit Tests
Developers
Testing Pyramid
UI
SERVICE
UNIT
Automated UI Tests
Automated API Tests
Automated Unit Tests
Compound
Isolation
Developers
Circle of Impact – changing core
Core
S1
S2
S3
A1
A2
A3
Circle of Impact – changing core
Core
S1
S2
S3
A1
A2
A3
Circle of Impact – changing core
Core
S1
S2
S3
A1
A2
A3
Circle of Impact – changing service
Core
S1
S2
S3
A1
A2
A3
Circle of Impact – changing service
Core
S1
S2
S3
A1
A2
A3
Circle of Impact – changing service
Core
S1
S2
S3
A1
A2
A3
Agenda
1. Web Service introduction
2. What's in it for testers ?
3. Testing a Web Service
4. Cases
Testing a Web Service
• Pitfalls
• General advice
• Tools you can use
Pitfalls
• Using performance test tools
Pitfalls
• Using performance test tools
– Hard to use pre/post conditions
Pitfalls
• Using performance test tools
– Hard to use pre/post conditions
– Hard to create maintainable scripts
Pitfalls
• Using performance test tools
– Hard to use pre/post conditions
– Hard to create maintainable scripts
– Hard to combine testtypes
Pitfalls
• Using performance test tools
– Hard to use pre/post conditions
– Hard to create maintainable scripts
– Hard to combine testtypes
– Hard to make complex assertions
Pitfalls
• Using performance test tools
– Hard to use pre/post conditions
– Hard to create maintainable scripts
– Hard to combine testtypes
– Hard to make complex assertions
– Limited flexibility in creating test suites
General advice
• Use a programming language
General advice
• Use a programming language
– IDE features
• Auto-completion, refactoring
General advice
• Use a programming language
– IDE features
• Auto-completion, refactoring
– Apply design patterns
• Make it maintainable and DRY (don’t repeat yourself)
General advice
• Use a programming language
– IDE features
• Auto-completion, refactoring
– Apply design patterns
• Make it maintainable and DRY (don’t repeat yourself)
– Flexible pre/post conditions
General advice
• Use a programming language
– IDE features
• Auto-completion, refactoring
– Apply design patterns
• Make it maintainable and DRY (don’t repeat yourself)
– Flexible pre/post conditions
– Combine your Selenium tests with web service tests
Tools you can use
• Jersey
– Making REST requests
• Jackson
– JSON processor
• JAXB
– XML processor
• JsonPath
– Extract parts of a JSON document
Tools you can use
• TestNG
– Java testing framework
• XMLUnit
– Assertions for XML, validate against XSD schema
• Hamcrest
– General matcher library
Agenda
1. Web Service introduction
2. What's in it for testers ?
3. Testing a Web Service
4. Cases
Case 1
Imagine you work for a Dutch Railway company. They
decide to create a public API, so developers can embed
railway information into their application.
You (as a tester) have to test the service.
Create a GET request
Client client = Client.create();
WebResource webResource =
client.resource("http://webservices.ns.nl");
MultivaluedMap<String, String> params = new
MultivaluedMapImpl();
params.add("station", "ut");
ClientResponse response = webResource.path("ns-api-avt")
.queryParams(params).accept("text/xml")
.get(ClientResponse.class);
if(response.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ response.getStatus());
}
System.out.println(response.getEntity(String.class));
Output: Failed : HTTP error code : 401
Create a GET request
Client client = Client.create();
WebResource webResource =
client.resource("http://webservices.ns.nl");
MultivaluedMap<String, String> params = new
MultivaluedMapImpl();
params.add("station", "ut");
ClientResponse response = webResource.path("ns-api-avt")
.queryParams(params).accept("text/xml")
.get(ClientResponse.class);
if(response.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ response.getStatus());
}
System.out.println(response.getEntity(String.class));
Output: Failed : HTTP error code : 401
Create a GET request
Client client = Client.create();
WebResource webResource =
client.resource("http://webservices.ns.nl");
MultivaluedMap<String, String> params = new
MultivaluedMapImpl();
params.add("station", "ut");
ClientResponse response = webResource.path("ns-api-avt")
.queryParams(params).accept("text/xml")
.get(ClientResponse.class);
if(response.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ response.getStatus());
}
System.out.println(response.getEntity(String.class));
Output: Failed : HTTP error code : 401
Create a GET request
Client client = Client.create();
WebResource webResource =
client.resource("http://webservices.ns.nl");
MultivaluedMap<String, String> params = new
MultivaluedMapImpl();
params.add("station", "ut");
ClientResponse response = webResource.path("ns-api-avt")
.queryParams(params).accept("text/xml")
.get(ClientResponse.class);
if(response.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ response.getStatus());
}
System.out.println(response.getEntity(String.class));
Output: Failed : HTTP error code : 401
Create a GET request
Client client = Client.create();
WebResource webResource =
client.resource("http://webservices.ns.nl");
MultivaluedMap<String, String> params = new
MultivaluedMapImpl();
params.add("station", "ut");
ClientResponse response = webResource.path("ns-api-avt")
.queryParams(params).accept("text/xml")
.get(ClientResponse.class);
if(response.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ response.getStatus());
}
System.out.println(response.getEntity(String.class));
Output: Failed : HTTP error code : 401
Create a GET request
Client client = Client.create();
WebResource webResource =
client.resource("http://webservices.ns.nl");
MultivaluedMap<String, String> params = new
MultivaluedMapImpl();
params.add("station", "ut");
ClientResponse response = webResource.path("ns-api-avt")
.queryParams(params).accept("text/xml")
.get(ClientResponse.class);
if(response.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ response.getStatus());
}
System.out.println(response.getEntity(String.class));
Output: Failed : HTTP error code : 401
Create a GET request
Client client = Client.create();
WebResource webResource =
client.resource("http://webservices.ns.nl");
MultivaluedMap<String, String> params = new
MultivaluedMapImpl();
params.add("station", "ut");
ClientResponse response = webResource.path("ns-api-avt")
.queryParams(params).accept("text/xml")
.get(ClientResponse.class);
if(response.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ response.getStatus());
}
System.out.println(response.getEntity(String.class));
Output: Failed : HTTP error code : 401
Set request headers
Basic Authentication
Client client = Client.create();
client.addFilter(new HTTPBasicAuthFilter("username",
"password"));
Other headers
ClientResponse response = webResource.path("ns-api-avt")
.queryParams(params).accept("text/xml")
.header("key", "value").get(ClientResponse.class);
Set request headers
Basic Authentication
Client client = Client.create();
client.addFilter(new HTTPBasicAuthFilter("username",
"password"));
Other headers
ClientResponse response = webResource.path("ns-api-avt")
.queryParams(params).accept("text/xml")
.header("key", "value").get(ClientResponse.class);
Set request headers
Basic Authentication
Client client = Client.create();
client.addFilter(new HTTPBasicAuthFilter("username",
"password"));
Other headers
ClientResponse response = webResource.path("ns-api-avt")
.queryParams(params).accept("text/xml")
.header("key", "value").get(ClientResponse.class);
Case 2
Imagine you have to control a relatively difficult XML-
string.
XML-response
<ActueleVertrekTijden>
<VertrekkendeTrein>
<RitNummer>3146</RitNummer>
<VertrekTijd>2013-06-13T14:28:00+0200</VertrekTijd>
<EindBestemming>Schiphol</EindBestemming>
<TreinSoort>Intercity</TreinSoort>
<RouteTekst>Bijlmer ArenA, A'dam Zuid</RouteTekst>
<Vervoerder>NS</Vervoerder>
<VertrekSpoor wijziging="true">5</VertrekSpoor>
</VertrekkendeTrein>
....
....
</ActueleVertrekTijden>
XML-response
<ActueleVertrekTijden>
<VertrekkendeTrein>
<RitNummer>3146</RitNummer>
<VertrekTijd>2013-06-13T14:28:00+0200</VertrekTijd>
<EindBestemming>Schiphol</EindBestemming>
<TreinSoort>Intercity</TreinSoort>
<RouteTekst>Bijlmer ArenA, A'dam Zuid</RouteTekst>
<Vervoerder>NS</Vervoerder>
<VertrekSpoor wijziging="true">5</VertrekSpoor>
</VertrekkendeTrein>
....
....
</ActueleVertrekTijden>
XML-response
<ActueleVertrekTijden>
<VertrekkendeTrein>
<RitNummer>3146</RitNummer>
<VertrekTijd>2013-06-13T14:28:00+0200</VertrekTijd>
<EindBestemming>Schiphol</EindBestemming>
<TreinSoort>Intercity</TreinSoort>
<RouteTekst>Bijlmer ArenA, A'dam Zuid</RouteTekst>
<Vervoerder>NS</Vervoerder>
<VertrekSpoor wijziging="true">5</VertrekSpoor>
</VertrekkendeTrein>
....
....
</ActueleVertrekTijden>
XML-response
<ActueleVertrekTijden>
<VertrekkendeTrein>
<RitNummer>3146</RitNummer>
<VertrekTijd>2013-06-13T14:28:00+0200</VertrekTijd>
<EindBestemming>Schiphol</EindBestemming>
<TreinSoort>Intercity</TreinSoort>
<RouteTekst>Bijlmer ArenA, A'dam Zuid</RouteTekst>
<Vervoerder>NS</Vervoerder>
<VertrekSpoor wijziging="true">5</VertrekSpoor>
</VertrekkendeTrein>
....
....
</ActueleVertrekTijden>
Create POJO (1)
POJO = Plain Old Java Object (nothing special)
- Create a class
- Implement fields (corresponding to XML elements)
- Generate getters/setters
- Map Getters to XML elements
- By annotations
In eclipse:
Right-click on the class file -> Source -> Generate Getters/Setters
Create POJO (2)
@XmlRootElement(name = "ActueleVertrekTijden")
public class ActueleVertrekTijden {
private List<VertrekkendeTrein> vertrekkendeTrein;
@XmlElement(name = "VertrekkendeTrein")
public List<VertrekkendeTrein> getVertrekkendeTrein() {
return vertrekkendeTrein;
}
public void setVertrekkendeTrein(List<VertrekkendeTrein>
vertrekkendeTrein) {
this.vertrekkendeTrein = vertrekkendeTrein;
}
}
Create POJO (2)
@XmlRootElement(name = "ActueleVertrekTijden")
public class ActueleVertrekTijden {
private List<VertrekkendeTrein> vertrekkendeTrein;
@XmlElement(name = "VertrekkendeTrein")
public List<VertrekkendeTrein> getVertrekkendeTrein() {
return vertrekkendeTrein;
}
public void setVertrekkendeTrein(List<VertrekkendeTrein>
vertrekkendeTrein) {
this.vertrekkendeTrein = vertrekkendeTrein;
}
}
Create POJO (2)
@XmlRootElement(name = "ActueleVertrekTijden")
public class ActueleVertrekTijden {
private List<VertrekkendeTrein> vertrekkendeTrein;
@XmlElement(name = "VertrekkendeTrein")
public List<VertrekkendeTrein> getVertrekkendeTrein() {
return vertrekkendeTrein;
}
public void setVertrekkendeTrein(List<VertrekkendeTrein>
vertrekkendeTrein) {
this.vertrekkendeTrein = vertrekkendeTrein;
}
}
Create POJO (3)
public class VertrekkendeTrein {
private int ritNummer;
private String vertrekTijd;
private String eindBestemming;
private String treinSoort;
private String routeTekst;
private String vervoerder;
private String vertrekSpoor;
@XmlElement(name = "RitNummer")
public int getRitNummer() {
return ritNummer;
}
public void setRitNummer(int ritNummer) {
this.ritNummer = ritNummer;
}
Create POJO (3)
public class VertrekkendeTrein {
private int ritNummer;
private String vertrekTijd;
private String eindBestemming;
private String treinSoort;
private String routeTekst;
private String vervoerder;
private String vertrekSpoor;
@XmlElement(name = "RitNummer")
public int getRitNummer() {
return ritNummer;
}
public void setRitNummer(int ritNummer) {
this.ritNummer = ritNummer;
}
Create POJO (3)
public class VertrekkendeTrein {
private int ritNummer;
private String vertrekTijd;
private String eindBestemming;
private String treinSoort;
private String routeTekst;
private String vervoerder;
private String vertrekSpoor;
@XmlElement(name = "RitNummer")
public int getRitNummer() {
return ritNummer;
}
public void setRitNummer(int ritNummer) {
this.ritNummer = ritNummer;
}
<RitNummer>
<VertrekTijd>
<EindBestemming>
<TreinSoort>
<RouteTekst>
<Vervoerder>
<VertrekSpoor>
Create POJO (3)
public class VertrekkendeTrein {
private int ritNummer;
private String vertrekTijd;
private String eindBestemming;
private String treinSoort;
private String routeTekst;
private String vervoerder;
private String vertrekSpoor;
@XmlElement(name = "RitNummer")
public int getRitNummer() {
return ritNummer;
}
public void setRitNummer(int ritNummer) {
this.ritNummer = ritNummer;
}
<RitNummer>
<VertrekTijd>
<EindBestemming>
<TreinSoort>
<RouteTekst>
<Vervoerder>
<VertrekSpoor>
Parse String to POJO
Output = response.getEntity(String.class);
Unmarshaller jaxbUnmarshaller =
jaxbContext.createUnmarshaller();
StringReader reader = new StringReader(output);
ActueleVertrekTijden actueleVertrekTijden =
(ActueleVertrekTijden) jaxbUnmarshaller
.unmarshal(reader);
System.out.println(actueleVertrekTijden.getVertrekkendeTrein()
.get(1).getEindBestemming());
Parse String to POJO
Output = response.getEntity(String.class);
Unmarshaller jaxbUnmarshaller =
jaxbContext.createUnmarshaller();
StringReader reader = new StringReader(output);
ActueleVertrekTijden actueleVertrekTijden =
(ActueleVertrekTijden) jaxbUnmarshaller
.unmarshal(reader);
System.out.println(actueleVertrekTijden.getVertrekkendeTrein()
.get(1).getEindBestemming());
Parse String to POJO
Output = response.getEntity(String.class);
Unmarshaller jaxbUnmarshaller =
jaxbContext.createUnmarshaller();
StringReader reader = new StringReader(output);
ActueleVertrekTijden actueleVertrekTijden =
(ActueleVertrekTijden) jaxbUnmarshaller
.unmarshal(reader);
System.out.println(actueleVertrekTijden.getVertrekkendeTrein()
.get(1).getEindBestemming());
Parse String to POJO
Output = response.getEntity(String.class);
Unmarshaller jaxbUnmarshaller =
jaxbContext.createUnmarshaller();
StringReader reader = new StringReader(output);
ActueleVertrekTijden actueleVertrekTijden =
(ActueleVertrekTijden) jaxbUnmarshaller
.unmarshal(reader);
System.out.println(actueleVertrekTijden.getVertrekkendeTrein()
.get(1).getEindBestemming());
Handle Errors
<error>
<message>No station found for input ecvve</message>
</error>
if(xml.contains("error")){
// parse to error object
} else if(xml.contains("name")){
// parse to different object
}
Conclusion
If you want something that is:
– Easy to maintain
– Flexible
Use a programming language for your automated
testing.
Questions
Thank you!
Source available on GitHub:
https://github.com/roydekleijn/webservicetests
Book: https://leanpub.com/LearningSelenium/
Twitter: https://twitter.com/TheWebTester
LinkedIn: http://www.linkedin.com/in/roydekleijn
Website: http://rdekleijn.nl
Get your FREE copy using
coupon code: TADNL2013
(coupon code valid for 2 months)

More Related Content

What's hot

Ppt of soap ui
Ppt of soap uiPpt of soap ui
Ppt of soap uipkslide28
 
Improving the Design of Existing Software
Improving the Design of Existing SoftwareImproving the Design of Existing Software
Improving the Design of Existing SoftwareSteven Smith
 
Developing SharePoint Framework Solutions for the Enterprise - SEF 2019
Developing SharePoint Framework Solutions for the Enterprise - SEF 2019Developing SharePoint Framework Solutions for the Enterprise - SEF 2019
Developing SharePoint Framework Solutions for the Enterprise - SEF 2019Eric Shupps
 
Building a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring BootBuilding a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring BootOmri Spector
 
Hey My Web App is Slow Where is the Problem
Hey My Web App is Slow Where is the ProblemHey My Web App is Slow Where is the Problem
Hey My Web App is Slow Where is the ProblemColdFusionConference
 
Java APIs - the missing manual
Java APIs - the missing manualJava APIs - the missing manual
Java APIs - the missing manualHendrik Ebbers
 
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0Ganesh Kondal
 
Testing soa, web services and application development framework applications
Testing soa, web services and application development framework applicationsTesting soa, web services and application development framework applications
Testing soa, web services and application development framework applicationsInSync Conference
 
Delivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDelivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDmitry Buzdin
 
Making your API behave like a big boy
Making your API behave like a big boyMaking your API behave like a big boy
Making your API behave like a big boyAndrew Siemer
 
Zure Azure PaaS Zero to Hero - DevOps training day
Zure Azure PaaS Zero to Hero - DevOps training dayZure Azure PaaS Zero to Hero - DevOps training day
Zure Azure PaaS Zero to Hero - DevOps training dayOkko Oulasvirta
 
Oracle Application Testing Suite. Competitive Edge
Oracle Application Testing Suite. Competitive EdgeOracle Application Testing Suite. Competitive Edge
Oracle Application Testing Suite. Competitive EdgeMaija Laksa
 
Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - IntroductionWebStackAcademy
 
ProtractorJS for automated testing of Angular 1.x/2.x applications
ProtractorJS for automated testing of Angular 1.x/2.x applicationsProtractorJS for automated testing of Angular 1.x/2.x applications
ProtractorJS for automated testing of Angular 1.x/2.x applicationsBinary Studio
 
Real-World RESTful Service Development Problems and Solutions
Real-World RESTful Service Development Problems and SolutionsReal-World RESTful Service Development Problems and Solutions
Real-World RESTful Service Development Problems and SolutionsMasoud Kalali
 

What's hot (20)

Testing Angular
Testing AngularTesting Angular
Testing Angular
 
Ppt of soap ui
Ppt of soap uiPpt of soap ui
Ppt of soap ui
 
Improving the Design of Existing Software
Improving the Design of Existing SoftwareImproving the Design of Existing Software
Improving the Design of Existing Software
 
Developing SharePoint Framework Solutions for the Enterprise - SEF 2019
Developing SharePoint Framework Solutions for the Enterprise - SEF 2019Developing SharePoint Framework Solutions for the Enterprise - SEF 2019
Developing SharePoint Framework Solutions for the Enterprise - SEF 2019
 
Building a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring BootBuilding a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring Boot
 
Hey My Web App is Slow Where is the Problem
Hey My Web App is Slow Where is the ProblemHey My Web App is Slow Where is the Problem
Hey My Web App is Slow Where is the Problem
 
Java APIs - the missing manual
Java APIs - the missing manualJava APIs - the missing manual
Java APIs - the missing manual
 
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0
 
Testing soa, web services and application development framework applications
Testing soa, web services and application development framework applicationsTesting soa, web services and application development framework applications
Testing soa, web services and application development framework applications
 
Delivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDelivery Pipeline for Windows Machines
Delivery Pipeline for Windows Machines
 
Making your API behave like a big boy
Making your API behave like a big boyMaking your API behave like a big boy
Making your API behave like a big boy
 
Application Testing Suite
Application Testing SuiteApplication Testing Suite
Application Testing Suite
 
Oracle application testing suite online training
Oracle application testing suite online trainingOracle application testing suite online training
Oracle application testing suite online training
 
Zure Azure PaaS Zero to Hero - DevOps training day
Zure Azure PaaS Zero to Hero - DevOps training dayZure Azure PaaS Zero to Hero - DevOps training day
Zure Azure PaaS Zero to Hero - DevOps training day
 
Java 11 OMG
Java 11 OMGJava 11 OMG
Java 11 OMG
 
Oracle Application Testing Suite. Competitive Edge
Oracle Application Testing Suite. Competitive EdgeOracle Application Testing Suite. Competitive Edge
Oracle Application Testing Suite. Competitive Edge
 
Oracle API Gateway
Oracle API GatewayOracle API Gateway
Oracle API Gateway
 
Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - Introduction
 
ProtractorJS for automated testing of Angular 1.x/2.x applications
ProtractorJS for automated testing of Angular 1.x/2.x applicationsProtractorJS for automated testing of Angular 1.x/2.x applications
ProtractorJS for automated testing of Angular 1.x/2.x applications
 
Real-World RESTful Service Development Problems and Solutions
Real-World RESTful Service Development Problems and SolutionsReal-World RESTful Service Development Problems and Solutions
Real-World RESTful Service Development Problems and Solutions
 

Viewers also liked

Finding bugs, categorizing bugs and writing good bug reports
Finding bugs, categorizing bugs and writing good bug reportsFinding bugs, categorizing bugs and writing good bug reports
Finding bugs, categorizing bugs and writing good bug reportssachxn1
 
Test cases and bug report v3.2
Test cases and bug report v3.2Test cases and bug report v3.2
Test cases and bug report v3.2Andrey Oleynik
 
Bug reporting and tracking
Bug reporting and trackingBug reporting and tracking
Bug reporting and trackingVadym Muliavka
 
Practical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test AutomationPractical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test AutomationSauce Labs
 
Testing web services
Testing web servicesTesting web services
Testing web servicesTaras Lytvyn
 

Viewers also liked (6)

Web Services Testing
Web Services TestingWeb Services Testing
Web Services Testing
 
Finding bugs, categorizing bugs and writing good bug reports
Finding bugs, categorizing bugs and writing good bug reportsFinding bugs, categorizing bugs and writing good bug reports
Finding bugs, categorizing bugs and writing good bug reports
 
Test cases and bug report v3.2
Test cases and bug report v3.2Test cases and bug report v3.2
Test cases and bug report v3.2
 
Bug reporting and tracking
Bug reporting and trackingBug reporting and tracking
Bug reporting and tracking
 
Practical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test AutomationPractical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test Automation
 
Testing web services
Testing web servicesTesting web services
Testing web services
 

Similar to Structured Functional Automated Web Service Testing

Patterns and practices for building enterprise-scale HTML5 apps
Patterns and practices for building enterprise-scale HTML5 appsPatterns and practices for building enterprise-scale HTML5 apps
Patterns and practices for building enterprise-scale HTML5 appsPhil Leggetter
 
Web Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI ToolWeb Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI ToolSperasoft
 
Introduction to SoapUI day 1
Introduction to SoapUI day 1Introduction to SoapUI day 1
Introduction to SoapUI day 1Qualitest
 
Soap UI - Getting started
Soap UI - Getting startedSoap UI - Getting started
Soap UI - Getting startedQualitest
 
Cerberus : Framework for Manual and Automated Testing (Web Application)
Cerberus : Framework for Manual and Automated Testing (Web Application)Cerberus : Framework for Manual and Automated Testing (Web Application)
Cerberus : Framework for Manual and Automated Testing (Web Application)CIVEL Benoit
 
Cerberus_Presentation1
Cerberus_Presentation1Cerberus_Presentation1
Cerberus_Presentation1CIVEL Benoit
 
Do not automate GUI testing
Do not automate GUI testingDo not automate GUI testing
Do not automate GUI testingAtila Inovecký
 
Modernizing Testing as Apps Re-Architect
Modernizing Testing as Apps Re-ArchitectModernizing Testing as Apps Re-Architect
Modernizing Testing as Apps Re-ArchitectDevOps.com
 
Tools. Techniques. Trouble?
Tools. Techniques. Trouble?Tools. Techniques. Trouble?
Tools. Techniques. Trouble?Testplant
 
Microsoft power point automation-opensourcetestingtools_matrix-1
Microsoft power point   automation-opensourcetestingtools_matrix-1Microsoft power point   automation-opensourcetestingtools_matrix-1
Microsoft power point automation-opensourcetestingtools_matrix-1tactqa
 
Microsoft power point automation-opensourcetestingtools_matrix-1
Microsoft power point   automation-opensourcetestingtools_matrix-1Microsoft power point   automation-opensourcetestingtools_matrix-1
Microsoft power point automation-opensourcetestingtools_matrix-1tactqa
 
AWS Summit Auckland - Application Delivery Patterns for Developers
AWS Summit Auckland - Application Delivery Patterns for DevelopersAWS Summit Auckland - Application Delivery Patterns for Developers
AWS Summit Auckland - Application Delivery Patterns for DevelopersAmazon Web Services
 
Brightcove presentation on Automated Testing
Brightcove presentation on Automated TestingBrightcove presentation on Automated Testing
Brightcove presentation on Automated TestingMassTLC
 
Netserv Software Testing
Netserv Software TestingNetserv Software Testing
Netserv Software Testingsthicks14
 
How to Build Front-End Web Apps that Scale - FutureJS
How to Build Front-End Web Apps that Scale - FutureJSHow to Build Front-End Web Apps that Scale - FutureJS
How to Build Front-End Web Apps that Scale - FutureJSPhil Leggetter
 

Similar to Structured Functional Automated Web Service Testing (20)

Patterns and practices for building enterprise-scale HTML5 apps
Patterns and practices for building enterprise-scale HTML5 appsPatterns and practices for building enterprise-scale HTML5 apps
Patterns and practices for building enterprise-scale HTML5 apps
 
Web Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI ToolWeb Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI Tool
 
Testing Testing everywhere
Testing Testing everywhereTesting Testing everywhere
Testing Testing everywhere
 
Introduction to SoapUI day 1
Introduction to SoapUI day 1Introduction to SoapUI day 1
Introduction to SoapUI day 1
 
Soap UI - Getting started
Soap UI - Getting startedSoap UI - Getting started
Soap UI - Getting started
 
Cerberus : Framework for Manual and Automated Testing (Web Application)
Cerberus : Framework for Manual and Automated Testing (Web Application)Cerberus : Framework for Manual and Automated Testing (Web Application)
Cerberus : Framework for Manual and Automated Testing (Web Application)
 
Cerberus_Presentation1
Cerberus_Presentation1Cerberus_Presentation1
Cerberus_Presentation1
 
Do not automate GUI testing
Do not automate GUI testingDo not automate GUI testing
Do not automate GUI testing
 
Modernizing Testing as Apps Re-Architect
Modernizing Testing as Apps Re-ArchitectModernizing Testing as Apps Re-Architect
Modernizing Testing as Apps Re-Architect
 
Tools. Techniques. Trouble?
Tools. Techniques. Trouble?Tools. Techniques. Trouble?
Tools. Techniques. Trouble?
 
Rest assured
Rest assuredRest assured
Rest assured
 
SOA Testing
SOA TestingSOA Testing
SOA Testing
 
Microsoft power point automation-opensourcetestingtools_matrix-1
Microsoft power point   automation-opensourcetestingtools_matrix-1Microsoft power point   automation-opensourcetestingtools_matrix-1
Microsoft power point automation-opensourcetestingtools_matrix-1
 
Microsoft power point automation-opensourcetestingtools_matrix-1
Microsoft power point   automation-opensourcetestingtools_matrix-1Microsoft power point   automation-opensourcetestingtools_matrix-1
Microsoft power point automation-opensourcetestingtools_matrix-1
 
Abhilash Alwandi resume
Abhilash Alwandi resumeAbhilash Alwandi resume
Abhilash Alwandi resume
 
AWS Summit Auckland - Application Delivery Patterns for Developers
AWS Summit Auckland - Application Delivery Patterns for DevelopersAWS Summit Auckland - Application Delivery Patterns for Developers
AWS Summit Auckland - Application Delivery Patterns for Developers
 
Brightcove presentation on Automated Testing
Brightcove presentation on Automated TestingBrightcove presentation on Automated Testing
Brightcove presentation on Automated Testing
 
Netserv Software Testing
Netserv Software TestingNetserv Software Testing
Netserv Software Testing
 
How to Build Front-End Web Apps that Scale - FutureJS
How to Build Front-End Web Apps that Scale - FutureJSHow to Build Front-End Web Apps that Scale - FutureJS
How to Build Front-End Web Apps that Scale - FutureJS
 
Managing Your Cloud Assets
Managing Your Cloud AssetsManaging Your Cloud Assets
Managing Your Cloud Assets
 

Recently uploaded

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 

Recently uploaded (20)

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 

Structured Functional Automated Web Service Testing

  • 1. Structured Functional Automated Web Service Testing Roy de Kleijn
  • 2. Who am I ? • Technical Test Consultant • Trainer test automation • Involved in R&D activities • Blogs: – http://selenium.polteq.com – http://www.rdekleijn.nl
  • 3. Agenda 1. Web Service introduction 2. What's in it for testers ? 3. Testing a Web Service 4. Cases
  • 4. Agenda 1. Web Service introduction 2. What's in it for testers ? 3. Testing a Web Service 4. Cases
  • 5. What is a Web Service ? A Web service is a software component that can be accessed by another application (such as a client, a server or another Web service) through the use of generally available, ubiquitous protocols and transports, such as Hypertext Transport Protocol (HTTP). [Gartner]
  • 7. Web Service Based Architecture • Scalable
  • 8. Web Service Based Architecture • Scalable • Support for any application type
  • 9. Web Service Based Architecture • Scalable • Support for any application type • Language independent
  • 10. Web Service Based Architecture • Scalable • Support for any application type • Language independent • Central business logic
  • 11. Web Service Based Architecture • Scalable • Support for any application type • Language independent • Central business logic • Standardised integration
  • 12. Different types • Protocols: WSDL / SOAP / REST
  • 13. Different types • Protocols: WSDL / SOAP / REST • REST (Representational State Transfer) – Defined by HTTP interface
  • 14. Different types • Protocols: WSDL / SOAP / REST • REST (Representational State Transfer) – Defined by HTTP interface – Support of basic application methods (CRUD): • POST -> create new resource • GET -> retrieve resources • PUT -> replace existing resource • Delete -> remove a resource
  • 16. Architecture - SOA application DB Service 1 Service 2 Service 3
  • 19. How it works... • Request messages are send to a specific endpoint • Messages are mostly XML or JSON fragments • Client can optionally set headers
  • 20. Agenda 1. Web Service introduction 2. What's in it for testers ? 3. Testing a Web Service 4. Cases
  • 21. Benefits for a tester • Less brittle tests – No GUI involved, no browser time-outs
  • 22. Benefits for a tester • Less brittle tests – No GUI involved, no browser time-outs • Testing can start in an early phase
  • 23. Benefits for a tester • Less brittle tests – No GUI involved, no browser time-outs • Testing can start in an early phase • No access to the code required (might be benefitial though)
  • 25. Testing Pyramid UI SERVICE UNIT Automated UI Tests Automated API Tests Automated Unit Tests Developers
  • 26. Testing Pyramid UI SERVICE UNIT Automated UI Tests Automated API Tests Automated Unit Tests Compound Isolation Developers
  • 27. Circle of Impact – changing core Core S1 S2 S3 A1 A2 A3
  • 28. Circle of Impact – changing core Core S1 S2 S3 A1 A2 A3
  • 29. Circle of Impact – changing core Core S1 S2 S3 A1 A2 A3
  • 30. Circle of Impact – changing service Core S1 S2 S3 A1 A2 A3
  • 31. Circle of Impact – changing service Core S1 S2 S3 A1 A2 A3
  • 32. Circle of Impact – changing service Core S1 S2 S3 A1 A2 A3
  • 33. Agenda 1. Web Service introduction 2. What's in it for testers ? 3. Testing a Web Service 4. Cases
  • 34. Testing a Web Service • Pitfalls • General advice • Tools you can use
  • 36. Pitfalls • Using performance test tools – Hard to use pre/post conditions
  • 37. Pitfalls • Using performance test tools – Hard to use pre/post conditions – Hard to create maintainable scripts
  • 38. Pitfalls • Using performance test tools – Hard to use pre/post conditions – Hard to create maintainable scripts – Hard to combine testtypes
  • 39. Pitfalls • Using performance test tools – Hard to use pre/post conditions – Hard to create maintainable scripts – Hard to combine testtypes – Hard to make complex assertions
  • 40. Pitfalls • Using performance test tools – Hard to use pre/post conditions – Hard to create maintainable scripts – Hard to combine testtypes – Hard to make complex assertions – Limited flexibility in creating test suites
  • 41. General advice • Use a programming language
  • 42. General advice • Use a programming language – IDE features • Auto-completion, refactoring
  • 43. General advice • Use a programming language – IDE features • Auto-completion, refactoring – Apply design patterns • Make it maintainable and DRY (don’t repeat yourself)
  • 44. General advice • Use a programming language – IDE features • Auto-completion, refactoring – Apply design patterns • Make it maintainable and DRY (don’t repeat yourself) – Flexible pre/post conditions
  • 45. General advice • Use a programming language – IDE features • Auto-completion, refactoring – Apply design patterns • Make it maintainable and DRY (don’t repeat yourself) – Flexible pre/post conditions – Combine your Selenium tests with web service tests
  • 46. Tools you can use • Jersey – Making REST requests • Jackson – JSON processor • JAXB – XML processor • JsonPath – Extract parts of a JSON document
  • 47. Tools you can use • TestNG – Java testing framework • XMLUnit – Assertions for XML, validate against XSD schema • Hamcrest – General matcher library
  • 48. Agenda 1. Web Service introduction 2. What's in it for testers ? 3. Testing a Web Service 4. Cases
  • 49. Case 1 Imagine you work for a Dutch Railway company. They decide to create a public API, so developers can embed railway information into their application. You (as a tester) have to test the service.
  • 50. Create a GET request Client client = Client.create(); WebResource webResource = client.resource("http://webservices.ns.nl"); MultivaluedMap<String, String> params = new MultivaluedMapImpl(); params.add("station", "ut"); ClientResponse response = webResource.path("ns-api-avt") .queryParams(params).accept("text/xml") .get(ClientResponse.class); if(response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } System.out.println(response.getEntity(String.class)); Output: Failed : HTTP error code : 401
  • 51. Create a GET request Client client = Client.create(); WebResource webResource = client.resource("http://webservices.ns.nl"); MultivaluedMap<String, String> params = new MultivaluedMapImpl(); params.add("station", "ut"); ClientResponse response = webResource.path("ns-api-avt") .queryParams(params).accept("text/xml") .get(ClientResponse.class); if(response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } System.out.println(response.getEntity(String.class)); Output: Failed : HTTP error code : 401
  • 52. Create a GET request Client client = Client.create(); WebResource webResource = client.resource("http://webservices.ns.nl"); MultivaluedMap<String, String> params = new MultivaluedMapImpl(); params.add("station", "ut"); ClientResponse response = webResource.path("ns-api-avt") .queryParams(params).accept("text/xml") .get(ClientResponse.class); if(response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } System.out.println(response.getEntity(String.class)); Output: Failed : HTTP error code : 401
  • 53. Create a GET request Client client = Client.create(); WebResource webResource = client.resource("http://webservices.ns.nl"); MultivaluedMap<String, String> params = new MultivaluedMapImpl(); params.add("station", "ut"); ClientResponse response = webResource.path("ns-api-avt") .queryParams(params).accept("text/xml") .get(ClientResponse.class); if(response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } System.out.println(response.getEntity(String.class)); Output: Failed : HTTP error code : 401
  • 54. Create a GET request Client client = Client.create(); WebResource webResource = client.resource("http://webservices.ns.nl"); MultivaluedMap<String, String> params = new MultivaluedMapImpl(); params.add("station", "ut"); ClientResponse response = webResource.path("ns-api-avt") .queryParams(params).accept("text/xml") .get(ClientResponse.class); if(response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } System.out.println(response.getEntity(String.class)); Output: Failed : HTTP error code : 401
  • 55. Create a GET request Client client = Client.create(); WebResource webResource = client.resource("http://webservices.ns.nl"); MultivaluedMap<String, String> params = new MultivaluedMapImpl(); params.add("station", "ut"); ClientResponse response = webResource.path("ns-api-avt") .queryParams(params).accept("text/xml") .get(ClientResponse.class); if(response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } System.out.println(response.getEntity(String.class)); Output: Failed : HTTP error code : 401
  • 56. Create a GET request Client client = Client.create(); WebResource webResource = client.resource("http://webservices.ns.nl"); MultivaluedMap<String, String> params = new MultivaluedMapImpl(); params.add("station", "ut"); ClientResponse response = webResource.path("ns-api-avt") .queryParams(params).accept("text/xml") .get(ClientResponse.class); if(response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } System.out.println(response.getEntity(String.class)); Output: Failed : HTTP error code : 401
  • 57. Set request headers Basic Authentication Client client = Client.create(); client.addFilter(new HTTPBasicAuthFilter("username", "password")); Other headers ClientResponse response = webResource.path("ns-api-avt") .queryParams(params).accept("text/xml") .header("key", "value").get(ClientResponse.class);
  • 58. Set request headers Basic Authentication Client client = Client.create(); client.addFilter(new HTTPBasicAuthFilter("username", "password")); Other headers ClientResponse response = webResource.path("ns-api-avt") .queryParams(params).accept("text/xml") .header("key", "value").get(ClientResponse.class);
  • 59. Set request headers Basic Authentication Client client = Client.create(); client.addFilter(new HTTPBasicAuthFilter("username", "password")); Other headers ClientResponse response = webResource.path("ns-api-avt") .queryParams(params).accept("text/xml") .header("key", "value").get(ClientResponse.class);
  • 60. Case 2 Imagine you have to control a relatively difficult XML- string.
  • 65. Create POJO (1) POJO = Plain Old Java Object (nothing special) - Create a class - Implement fields (corresponding to XML elements) - Generate getters/setters - Map Getters to XML elements - By annotations In eclipse: Right-click on the class file -> Source -> Generate Getters/Setters
  • 66. Create POJO (2) @XmlRootElement(name = "ActueleVertrekTijden") public class ActueleVertrekTijden { private List<VertrekkendeTrein> vertrekkendeTrein; @XmlElement(name = "VertrekkendeTrein") public List<VertrekkendeTrein> getVertrekkendeTrein() { return vertrekkendeTrein; } public void setVertrekkendeTrein(List<VertrekkendeTrein> vertrekkendeTrein) { this.vertrekkendeTrein = vertrekkendeTrein; } }
  • 67. Create POJO (2) @XmlRootElement(name = "ActueleVertrekTijden") public class ActueleVertrekTijden { private List<VertrekkendeTrein> vertrekkendeTrein; @XmlElement(name = "VertrekkendeTrein") public List<VertrekkendeTrein> getVertrekkendeTrein() { return vertrekkendeTrein; } public void setVertrekkendeTrein(List<VertrekkendeTrein> vertrekkendeTrein) { this.vertrekkendeTrein = vertrekkendeTrein; } }
  • 68. Create POJO (2) @XmlRootElement(name = "ActueleVertrekTijden") public class ActueleVertrekTijden { private List<VertrekkendeTrein> vertrekkendeTrein; @XmlElement(name = "VertrekkendeTrein") public List<VertrekkendeTrein> getVertrekkendeTrein() { return vertrekkendeTrein; } public void setVertrekkendeTrein(List<VertrekkendeTrein> vertrekkendeTrein) { this.vertrekkendeTrein = vertrekkendeTrein; } }
  • 69. Create POJO (3) public class VertrekkendeTrein { private int ritNummer; private String vertrekTijd; private String eindBestemming; private String treinSoort; private String routeTekst; private String vervoerder; private String vertrekSpoor; @XmlElement(name = "RitNummer") public int getRitNummer() { return ritNummer; } public void setRitNummer(int ritNummer) { this.ritNummer = ritNummer; }
  • 70. Create POJO (3) public class VertrekkendeTrein { private int ritNummer; private String vertrekTijd; private String eindBestemming; private String treinSoort; private String routeTekst; private String vervoerder; private String vertrekSpoor; @XmlElement(name = "RitNummer") public int getRitNummer() { return ritNummer; } public void setRitNummer(int ritNummer) { this.ritNummer = ritNummer; }
  • 71. Create POJO (3) public class VertrekkendeTrein { private int ritNummer; private String vertrekTijd; private String eindBestemming; private String treinSoort; private String routeTekst; private String vervoerder; private String vertrekSpoor; @XmlElement(name = "RitNummer") public int getRitNummer() { return ritNummer; } public void setRitNummer(int ritNummer) { this.ritNummer = ritNummer; } <RitNummer> <VertrekTijd> <EindBestemming> <TreinSoort> <RouteTekst> <Vervoerder> <VertrekSpoor>
  • 72. Create POJO (3) public class VertrekkendeTrein { private int ritNummer; private String vertrekTijd; private String eindBestemming; private String treinSoort; private String routeTekst; private String vervoerder; private String vertrekSpoor; @XmlElement(name = "RitNummer") public int getRitNummer() { return ritNummer; } public void setRitNummer(int ritNummer) { this.ritNummer = ritNummer; } <RitNummer> <VertrekTijd> <EindBestemming> <TreinSoort> <RouteTekst> <Vervoerder> <VertrekSpoor>
  • 73. Parse String to POJO Output = response.getEntity(String.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); StringReader reader = new StringReader(output); ActueleVertrekTijden actueleVertrekTijden = (ActueleVertrekTijden) jaxbUnmarshaller .unmarshal(reader); System.out.println(actueleVertrekTijden.getVertrekkendeTrein() .get(1).getEindBestemming());
  • 74. Parse String to POJO Output = response.getEntity(String.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); StringReader reader = new StringReader(output); ActueleVertrekTijden actueleVertrekTijden = (ActueleVertrekTijden) jaxbUnmarshaller .unmarshal(reader); System.out.println(actueleVertrekTijden.getVertrekkendeTrein() .get(1).getEindBestemming());
  • 75. Parse String to POJO Output = response.getEntity(String.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); StringReader reader = new StringReader(output); ActueleVertrekTijden actueleVertrekTijden = (ActueleVertrekTijden) jaxbUnmarshaller .unmarshal(reader); System.out.println(actueleVertrekTijden.getVertrekkendeTrein() .get(1).getEindBestemming());
  • 76. Parse String to POJO Output = response.getEntity(String.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); StringReader reader = new StringReader(output); ActueleVertrekTijden actueleVertrekTijden = (ActueleVertrekTijden) jaxbUnmarshaller .unmarshal(reader); System.out.println(actueleVertrekTijden.getVertrekkendeTrein() .get(1).getEindBestemming());
  • 77. Handle Errors <error> <message>No station found for input ecvve</message> </error> if(xml.contains("error")){ // parse to error object } else if(xml.contains("name")){ // parse to different object }
  • 78. Conclusion If you want something that is: – Easy to maintain – Flexible Use a programming language for your automated testing.
  • 80. Thank you! Source available on GitHub: https://github.com/roydekleijn/webservicetests Book: https://leanpub.com/LearningSelenium/ Twitter: https://twitter.com/TheWebTester LinkedIn: http://www.linkedin.com/in/roydekleijn Website: http://rdekleijn.nl Get your FREE copy using coupon code: TADNL2013 (coupon code valid for 2 months)

Editor's Notes

  1. Web Services make it possible to expose application functionality to the out-side world using a standardized protocol. It’s more frequently used these days to enable direct interaction between applications, so multiple applications can use the same web services. It has to be good! In this track you will see how you can develop a structured framework to create maintainable/reusable functional automated web service tests.
  2. Technisch test specialistIk geef twee testautomatiserings trainingenEn daarnaast ben ik betrokken bij enkele innovatie projecten binnen polteqTot slot onderhoud ik 2 blogs:Op selenium.polteq.com staan Selenium gerelateerde tutorialsOp mijn persoonlijk blog staan test-gerelateerde artikellen
  3. http://www.slideshare.net/cesare.pautasso/some-rest-design-patterns-and-antipatterns?from_search=4http://www.autotestguy.com/archives/design_patterns/index.htmlDesign Patterns -&gt; have to researchClient c = Client.create(); WebResource w = c.resource(&quot;http://host/path&quot;); String s = w.header(&quot;name&quot;, &quot;value&quot;).get(String.class); or you can use client filter as well:          Client c = Client.create();          c.addFilter(new ClientFilter() {              @Override              public ClientResponse handle(ClientRequestcr) throws ClientHandlerException {                  cr.getHeaders(); // do what you want                  return getNext().handle(cr);              }          });
  4. http://www.slideshare.net/cesare.pautasso/some-rest-design-patterns-and-antipatterns?from_search=4http://www.autotestguy.com/archives/design_patterns/index.htmlDesign Patterns -&gt; have to researchClient c = Client.create(); WebResource w = c.resource(&quot;http://host/path&quot;); String s = w.header(&quot;name&quot;, &quot;value&quot;).get(String.class); or you can use client filter as well:          Client c = Client.create();          c.addFilter(new ClientFilter() {              @Override              public ClientResponse handle(ClientRequestcr) throws ClientHandlerException {                  cr.getHeaders(); // do what you want                  return getNext().handle(cr);              }          });
  5. Application contains all business logic and can access the database directly.If you build a second application with more-or-less the same functionality, then you need to copy all businnes logic.
  6. By introducing a web service based archticture we try to make it more scalable and accesible for any application type
  7. By introducing a web service based archticture we try to make it more scalable and accesible for any application type
  8. By introducing a web service based archticture we try to make it more scalable and accesible for any application type
  9. By introducing a web service based archticture we try to make it more scalable and accesible for any application type
  10. By introducing a web service based archticture we try to make it more scalable and accesible for any application type
  11. Application contains less business logic. It’s split over multiple services.There is a agreement on the messages which can be send. The response formats are also known.
  12. Application contains less business logic. It’s split over multiple services.There is a agreement on the messages which can be send. The response formats are also known.
  13. Why not using Jmeter:Hard to perform pre/post conditionsHard to create maintainable scriptsHard to combin tests (Use webservice and verify on website)Hard to make complex asertions (complex JSON objects)Less flexibility in creating test suites
  14. http://www.slideshare.net/cesare.pautasso/some-rest-design-patterns-and-antipatterns?from_search=4http://www.autotestguy.com/archives/design_patterns/index.htmlDesign Patterns -&gt; have to researchClient c = Client.create(); WebResource w = c.resource(&quot;http://host/path&quot;); String s = w.header(&quot;name&quot;, &quot;value&quot;).get(String.class); or you can use client filter as well:          Client c = Client.create();          c.addFilter(new ClientFilter() {              @Override              public ClientResponse handle(ClientRequestcr) throws ClientHandlerException {                  cr.getHeaders(); // do what you want                  return getNext().handle(cr);              }          });
  15. NS applicationImagine you work for a Dutch Railway company. They decided to develop a public API, so developers can embed railway information into their application.
  16. NS applicationImagine you work for a Dutch Railway company. They decided to develop a public API, so developers can embed railway information into their application.