API Testing. Streamline your testing process.

Andrey Oleynik
Andrey OleynikSenior QA Automation Engineer, Senior QA Engineer, QA Automation lead at DataArt Poland Wroclaw
API Testing:
Streamline your testing process
Andrii Olieinik
Senior QA Automation Engineer
About me
• Senior QA Automation Engineer
• About 10 years of work in Quality Assurance area
• PhD, Theoretical physics
2
Agenda
• UI testing vs. API testing
• Testing pyramid
• HTTP/HTTPS
• Web services
• SOAP
• REST
• Tools
• Postman
• SoapUI
• REST
• Homework
3
UI test duration
4
Automated UI testing vs. automated API testing
Automated API test Automated UI test
Depends on API yes yes
Depends on UI no yes
Duration ~1..10^2 ms ~1..10^2 s and more
5
Testing pyramid
6
Unit tests
API tests
GUI tests
Ice Cream Cone
7
Testing Cupcake
8
Testing pyramid
9
Unit tests
API tests
GUI tests
Testing pyramid
10
Unit tests
API tests
GUI tests
Web services
• The W3C defines a "Web service" as "a software system designed to support interoperable
machine-to-machine interaction over a network".
• In a Web service, Web technology such as the HTTP, originally designed for human-to-machine
communication, is utilized for machine-to-machine communication, more specifically for
transferring machine readable file formats such as XML and JSON.
Types:
• SOAP
• RESTful
• …
11
Web services
12
Hypertext Transfer Protocol
• The Hypertext Transfer Protocol (HTTP) is an application protocol for distributed, collaborative,
hypermedia information systems. HTTP is the foundation of data communication for the World
Wide Web.
13
HTTP
• HTTP is connectionless
• HTTP is media independent
• HTTP is stateless
14
HTTP
• HTTP Version (HTTP/1.0)
• Uniform Resource Identifiers
• Character Sets (US-ASCII)
• Content Encodings (Accept-encoding: gzip)
• Media Types (application/json)
• Header Fields
• Message Body
• Response code
15
HTTP headers
16
HTTP methods
• GET - to retrieve information from the given server using a given URI. Requests using GET should
only retrieve data and should have no other effect on the data
• HEAD - Same as GET, but it transfers the status line and the header section only
• POST - A POST request is used to send data to the server using HTML forms
• PUT - Replaces all the current representations of the target resource with the uploaded content
• DELETE - Removes all the current representations of the target resource given by URI
• CONNECT - Establishes a tunnel to the server identified by a given URI
• OPTIONS - Describe the communication options for the target resource
• TRACE - Performs a message loop back test along with the path to the target resource
• PATCH - The PATCH method applies partial modifications to a resource
17
REST
• REST stands for Representational State Transfer. (It is sometimes spelled "ReST".) It relies on a
stateless, client-server, cacheable communications protocol -- and in virtually all cases, the HTTP
protocol is used. REST is an architecture style for designing networked applications.
• REST is an architecture style for designing networked applications. The idea is that, rather than
using complex mechanisms such as CORBA, RPC or SOAP to connect between machines, simple
HTTP is used to make calls between machines.
18
REST demo
• JSONPlaceholder: https://jsonplaceholder.typicode.com/
• National Digital Forecast Database (NDFD) REST Web Service:
http://graphical.weather.gov/xml/rest.php
• Narodowy Bank Polski: http://api.nbp.pl/en.html
19
REST
• Endpoint
• Resource
• Methods (Post/Get/…)
• Media type for the data (JSON, XML)
20
CRUD
CRUD
• Create
• Read
• Update
• Delete
HTTP
• Post
• Get
• Put
• Delete
21
Tools
• Postman
• SoapUI
• Jmeter
• REST Assured: https://github.com/rest-assured/rest-assured
• Apache HttpClient: http://hc.apache.org
• Async Http Client: https://github.com/AsyncHttpClient/async-http-client
• RestTemplate https://docs.spring.io/spring/docs/current/javadoc-
api/org/springframework/web/client/RestTemplate.html
• …
22
Postman
23
Postman
• REST requests
• SOAP requests +/-
• Collections (test sets)
• Scripts
• Variables
• Execute from command line (with Newman)
• Integration with CI (with Newman)
• JUnit reports (with Newman)
• Web Service Mocking
24
SoapUI
25
SoapUI
• REST requests
• SOAP requests
• Tests
• Test suits
• Scripts
• Variables
• Execute from command line
• Integration with CI
• Integration with Maven
• JUnit reports
• Web Service Mocking 26
SoapUI testcase
27
SoapUI assertions
28
More details
• Postman docs: https://www.getpostman.com/docs/
• Scripts in Postman: https://www.getpostman.com/docs/postman/scripts/intro_to_scripts
• Structuring and Running Tests (SoapUI): https://www.soapui.org/Functional-Testing/structuring-
and-running-tests.html
• Getting Started with REST Testing in SoapUI: https://www.soapui.org/rest-testing/getting-
started.html
• Newman: https://github.com/postmanlabs/newman
• JSON Formatter & Validator: https://jsonformatter.curiousconcept.com/
• JSONLint - The JSON Validator: http://jsonlint.com/
29
WSDL
• Web Services Description Language (WSDL, pronounced 'wiz-dul') is an XML-based language
that is used for describing the functionality offered by a Web service. A WSDL description of a web
service (also referred to as a WSDL file) provides a machine-readable description of how the
service can be called, what parameters it expects and what data structures it returns. WSDL
stands for Web Services Description Language
• WSDL is used to describe web services
• WSDL is written in XML
• WSDL is a W3C recommendation
30
WSDL parts
• Data types definition (types) – the definition of sent and received XML service messages.
• Data elements (message) – message used by web-service.
• Abstract operations (portType) – the list of operations that can be performed with messages.
• Service binding (binding) – the way the message will be delivered
31
WSDL examples
• ISBN Test: http://webservices.daehosting.com/services/isbnservice.wso?WSDL
• Country Information:
http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL
• Number Conversion:
http://www.dataaccess.com/webservicesserver/numberconversion.wso?WSDL
• Bankleitzahlen Service: http://www.thomas-bayer.com/axis2/services/BLZService?wsdl
• National Digital Forecast Database (NDFD) SOAP Web Service: http://graphical.weather.gov/xml/
32
SOAP
• SOAP stands for Simple Object Access Protocol
• SOAP is an application communication protocol
• SOAP is a format for sending and receiving messages
• SOAP is platform independent
• SOAP is based on XML
• SOAP is a W3C recommendation
33
SOAP
34
SOAP
35
Tools
• Postman
• SoapUI
• Axis: http://axis.apache.org/axis2/java/core/
• REST Assured: https://github.com/rest-assured/rest-assured
• Apache HttpClient: http://hc.apache.org
• Async Http Client: https://github.com/AsyncHttpClient/async-http-client
• RestTemplate https://docs.spring.io/spring/docs/current/javadoc-
api/org/springframework/web/client/RestTemplate.html
• …
36
More details
• w3schools about SOAP: http://www.w3schools.com/xml/xml_soap.asp
• w3schools about WSDL: http://www.w3schools.com/xml/xml_wsdl.asp
• SoapUI: https://www.soapui.org/downloads/soapui/alternate-platforms.html
• Your First SoapUI Project: https://www.soapui.org/getting-started/your-first-soapui-project.html
37
Possible task
• Create a project against any weather API. For example you can take NIST SOAP or REST service.
Get temperature for San Francisco at 9 a.m. on the day of your choice. Add assertion if the
temperature is grater than 0.
38
Questions
• Questions?
39
Project file
• Project data are stored in separate xmls files
40
Properties
• Project, TestSuite and TestCase have properties
41
Project properties
42
Properties Transfer
• Transferring Property Values: https://www.soapui.org/functional-testing/properties/transferring-
properties.html
43
Property Expansion
• ${#Scope#Property-name[#xpath-expression]}
• ${#Project#Property-name}refers to a Project Property
• ${#TestSuite#Property-name} refers to a TestSuite Property
• ${#TestCase#Property-name} refers to a TestCase Property
• ${TestStep-name#Property-name} refers to a property in a named TestStep.
44
Assertions (Property Content)
• Contains
• Not Contains
• JsonPath Count
• JsonPath Existance Match
• JsonPath Match
• JsonPath RegEx Match
• XPath Match
• XQuery Math
45
Assertions (Property Content)
46
Assertions (Property Content)
47
Assertions (Property Content)
• JsonPath Count
48
Assertions (Property Content)
• JsonPath Match
49
Assertions (Compliance, Status and Standarts)
• HTTP Download all resource
• Invalid HTTP Status Codes
• Not SOAP Fault
• Schema Compliance
• SOAP Fault
• SOAP Request
• SOAP Response
• Valid HTTP Status Codes
• WS-Addressing Request
• WS-Addressing Response
• WS-Security Status
50
Script assertion
51
Script assertion
• JsonSlurper
52
Other assertions
• SLA
• JMS
• JDBC
• Security
53
Groovy scripts
54
Groovy scripts
55
Setup/TearDown scripts
• Suite Setup/TearDown
• TestCase Setup/TearDown
56
Data Driven testing
57
Data Driven testing
58
Data Driven testing
59
Custom reporting
60
Custom reporting
61
Custom reporting
62
More details (Groovy)
• Groovy Documentation: http://groovy-lang.org/documentation.html
• Groovy JDK API Documentation: http://groovy-lang.org/gdk.html
• SoapUI Tips & Tricks: https://www.soapui.org/scripting-properties/tips-tricks.html
• 10 Groovy scripts on your finger tips – soapUI: https://learnsoapui.wordpress.com/2011/07/17/10-
groovy-scripts-on-your-finger-tips-soapui/
• SoapUI Groovy: Slurping JSON in Script Assertions:
https://thetestsuite.wordpress.com/2013/09/30/soapui-groovy-slurping-json-in-script-assertions/
• XML Parsing in soapUI: http://www.robert-nemet.com/2011/11/groovy-xml-parsing-in-soapui.html
63
TestRunner
64
TestRunner (options)
• ..SoapUI-5.2.1bintestrunner.bat
• testrunner.bat -s"TestSuite 1" -r -j D:REST-Project-1-soapui-project.xml -f D:SoapUI-5.2.1report
• a : Turns on exporting of all test results, not only errors
• c : The TestCase to run, used to narrow down the tests to run
• e : The endpoint to use when invoking test-requests, overrides the endpoint set in the project file
• f : Specifies the root folder to which test results should be exported
• j : Turns on exporting of JUnit-compatible reports, see below
• P : Sets project property with name=value, e.g. -Pendpoint=Value1 -PsomeOtherProperty=value2
• s : The TestSuite to run, used to narrow down the tests to run
65
SoapUI logs
• By default in ..SoapUI-5.2.1bin
• soapui-log4j.xml
• soapui.log
• soapui-errors.log
• global-groovy.log
66
Authorization
• Steps to run Twitter API with SoapUI: http://acodediary.com/twitter-api-with-soapui/
67
Authorization (generate bearer token)
68
Authorization (get access token)
69
Authorization (result)
70
Integration with Maven (project structure)
• To execute project run command: mvn integration-test
71
Integration with Maven (project structure)
72
Integration with Maven (execution result)
73
Integration with Maven (pom.xml)
74
Integration with Maven (pom.xml)
75
Integration with Maven (extensions)
• Put additional jars into ext folder
• Or add new module to the project
76
Listeners
• Create my-listeners.xml file in SoapUI-5.2.1binlisteners
• Create MyListener.java, compile it in jar file and put in SoapUI-5.2.1binext
• Create a directory build
• Run java compilation from the command line:
• javac -cp soapui-5.2.1.jar com/dataart/api/listeners/MyListener.java -d ./build
• Go to the build folder (cd build) and create a jar
• jar cvf YourJar.jar *
77
Listeners (source code)
78
Listeners (result)
79
More details
• Rupert Anderson SoapUI Cookbook
• Charitha Kankanamge Web Services Testing with soapUI
80
More details
• JSONPath - XPath for JSON: http://goessner.net/articles/JsonPath/
• Running Functional Tests (TestRunner): https://www.soapui.org/test-automation/running-functional-
tests.html
• SoapUI source code: https://github.com/SmartBear/soapui
• SoapUI and Maven: https://www.soapui.org/test-automation/maven/maven-2-x.html
• Source code in SoapUI maven: http://stackoverflow.com/questions/30320647/source-code-in-
soapui-maven
• Extending soapU: https://www.soapui.org/extension-plugins/old-style-extensions/developing-old-
style-extensions.html
• SoapUI JavaDoc: https://www.soapui.org/apidocs/allclasses-noframe.html
81
More details
• Custom report: https://github.com/a-oleynik/SoapUI/blob/master/CustomReport.groovy
• Maven project with SoapUI example: https://github.com/a-oleynik/SoapUI/tree/master/api-test
• Listener code example: https://github.com/a-oleynik/SoapUI/tree/master/Listener
82
Possible task
• Create custom report into an xml file.
• Create a Data Driven test and read data from excel file.
• Create a Maven project for your SoapUI project. Set the project up and execute it from the
command line.
83
Questions
• Questions?
84
1 de 84

Recomendados

B4USolution_API-TestingB4USolution_API-Testing
B4USolution_API-Testingb4usolution .
1.3K vistas31 diapositivas
API TestingAPI Testing
API TestingBikash Sharma
7.8K vistas9 diapositivas
Api TestingApi Testing
Api TestingVishwanath KC
1.4K vistas20 diapositivas

Más contenido relacionado

La actualidad más candente

Api testingApi testing
Api testingHamzaMajid13
825 vistas19 diapositivas
Rest assuredRest assured
Rest assuredVarun Deshpande
6.5K vistas11 diapositivas
How to Automate API TestingHow to Automate API Testing
How to Automate API TestingBruno Pedro
7.9K vistas27 diapositivas
Postman.pptPostman.ppt
Postman.pptParrotBAD
2.8K vistas28 diapositivas

La actualidad más candente(20)

Api testingApi testing
Api testing
HamzaMajid13825 vistas
Rest assuredRest assured
Rest assured
Varun Deshpande6.5K vistas
API Testing Using REST Assured with TestNGAPI Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNG
Siddharth Sharma1K vistas
How to Automate API TestingHow to Automate API Testing
How to Automate API Testing
Bruno Pedro7.9K vistas
Postman.pptPostman.ppt
Postman.ppt
ParrotBAD2.8K vistas
Api testingApi testing
Api testing
Keshav Kashyap30.1K vistas
Test Automation and SeleniumTest Automation and Selenium
Test Automation and Selenium
Karapet Sarkisyan2.4K vistas
API Test Automation API Test Automation
API Test Automation
SQALab1.9K vistas
PostmanPostman
Postman
Igor Shubovych7.5K vistas
Selenium test automationSelenium test automation
Selenium test automation
Srikanth Vuriti2.1K vistas

Similar a API Testing. Streamline your testing process.

Ntg   web servicesNtg   web services
Ntg web servicesFarag Zakaria
540 vistas48 diapositivas
RESTful webRESTful web
RESTful webAlvin Qi
2.1K vistas43 diapositivas
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiTiago Knoch
9.3K vistas30 diapositivas
Web ServicesWeb Services
Web ServicesKatrien Verbert
9.3K vistas63 diapositivas

Similar a API Testing. Streamline your testing process.(20)

Windows 8 Metro apps and the outside worldWindows 8 Metro apps and the outside world
Windows 8 Metro apps and the outside world
Prabhakaran Soundarapandian2.3K vistas
Ntg   web servicesNtg   web services
Ntg web services
Farag Zakaria540 vistas
RESTful webRESTful web
RESTful web
Alvin Qi2.1K vistas
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
Tiago Knoch9.3K vistas
Web ServicesWeb Services
Web Services
Katrien Verbert9.3K vistas
Windows 8 Apps and the Outside WorldWindows 8 Apps and the Outside World
Windows 8 Apps and the Outside World
Microsoft Developer Network (MSDN) - Belgium and Luxembourg2.1K vistas
SOA TestingSOA Testing
SOA Testing
Roopesh Kohad1.8K vistas
(ATS6-PLAT04) Query service (ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service
BIOVIA736 vistas
Excellent rest using asp.net web apiExcellent rest using asp.net web api
Excellent rest using asp.net web api
Maurice De Beijer [MVP]11.4K vistas
WEB TECHNOLOGY Unit-5.pptxWEB TECHNOLOGY Unit-5.pptx
WEB TECHNOLOGY Unit-5.pptx
karthiksmart214 vistas
REST API RecommendationsREST API Recommendations
REST API Recommendations
Jeelani Shaik329 vistas
Introduction to SignalRIntroduction to SignalR
Introduction to SignalR
Anthony Peruma1.7K vistas
Overview of java web servicesOverview of java web services
Overview of java web services
Todd Benson (I.T. SPECIALIST and I.T. SECURITY)1.5K vistas
Designing RESTful APIsDesigning RESTful APIs
Designing RESTful APIs
anandology750 vistas
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHP
Zoran Jeremic27.9K vistas
Consuming RESTful Web services in PHPConsuming RESTful Web services in PHP
Consuming RESTful Web services in PHP
Zoran Jeremic22.6K vistas
Basics of the Web PlatformBasics of the Web Platform
Basics of the Web Platform
Sanjeev Verma, PhD1.6K vistas
Restful风格ž„web服务架构Restful风格ž„web服务架构
Restful风格ž„web服务架构
Benjamin Tan756 vistas

Más de Andrey Oleynik

Deep dive into SoapUIDeep dive into SoapUI
Deep dive into SoapUIAndrey Oleynik
671 vistas62 diapositivas
TestNG vs. JUnit4TestNG vs. JUnit4
TestNG vs. JUnit4Andrey Oleynik
1.3K vistas46 diapositivas

Más de Andrey Oleynik(7)

IT Talk TestNG 6 vs JUnit 4IT Talk TestNG 6 vs JUnit 4
IT Talk TestNG 6 vs JUnit 4
Andrey Oleynik90 vistas
Deep dive into SoapUIDeep dive into SoapUI
Deep dive into SoapUI
Andrey Oleynik671 vistas
TestNG vs. JUnit4TestNG vs. JUnit4
TestNG vs. JUnit4
Andrey Oleynik1.3K vistas
Test cases and bug report v3.2Test cases and bug report v3.2
Test cases and bug report v3.2
Andrey Oleynik5.1K vistas

Último(20)

Tridens DevOpsTridens DevOps
Tridens DevOps
Tridens9 vistas
Neo4j y GenAI Neo4j y GenAI
Neo4j y GenAI
Neo4j27 vistas
Unleash The MonkeysUnleash The Monkeys
Unleash The Monkeys
Jacob Duijzer7 vistas
Winter '24 Release Chat.pdfWinter '24 Release Chat.pdf
Winter '24 Release Chat.pdf
melbourneauuser9 vistas
ict act 1.pptxict act 1.pptx
ict act 1.pptx
sanjaniarun0812 vistas
SAP FOR CONTRACT MANUFACTURING.pdfSAP FOR CONTRACT MANUFACTURING.pdf
SAP FOR CONTRACT MANUFACTURING.pdf
Virendra Rai, PMP11 vistas

API Testing. Streamline your testing process.

  • 1. API Testing: Streamline your testing process Andrii Olieinik Senior QA Automation Engineer
  • 2. About me • Senior QA Automation Engineer • About 10 years of work in Quality Assurance area • PhD, Theoretical physics 2
  • 3. Agenda • UI testing vs. API testing • Testing pyramid • HTTP/HTTPS • Web services • SOAP • REST • Tools • Postman • SoapUI • REST • Homework 3
  • 5. Automated UI testing vs. automated API testing Automated API test Automated UI test Depends on API yes yes Depends on UI no yes Duration ~1..10^2 ms ~1..10^2 s and more 5
  • 11. Web services • The W3C defines a "Web service" as "a software system designed to support interoperable machine-to-machine interaction over a network". • In a Web service, Web technology such as the HTTP, originally designed for human-to-machine communication, is utilized for machine-to-machine communication, more specifically for transferring machine readable file formats such as XML and JSON. Types: • SOAP • RESTful • … 11
  • 13. Hypertext Transfer Protocol • The Hypertext Transfer Protocol (HTTP) is an application protocol for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web. 13
  • 14. HTTP • HTTP is connectionless • HTTP is media independent • HTTP is stateless 14
  • 15. HTTP • HTTP Version (HTTP/1.0) • Uniform Resource Identifiers • Character Sets (US-ASCII) • Content Encodings (Accept-encoding: gzip) • Media Types (application/json) • Header Fields • Message Body • Response code 15
  • 17. HTTP methods • GET - to retrieve information from the given server using a given URI. Requests using GET should only retrieve data and should have no other effect on the data • HEAD - Same as GET, but it transfers the status line and the header section only • POST - A POST request is used to send data to the server using HTML forms • PUT - Replaces all the current representations of the target resource with the uploaded content • DELETE - Removes all the current representations of the target resource given by URI • CONNECT - Establishes a tunnel to the server identified by a given URI • OPTIONS - Describe the communication options for the target resource • TRACE - Performs a message loop back test along with the path to the target resource • PATCH - The PATCH method applies partial modifications to a resource 17
  • 18. REST • REST stands for Representational State Transfer. (It is sometimes spelled "ReST".) It relies on a stateless, client-server, cacheable communications protocol -- and in virtually all cases, the HTTP protocol is used. REST is an architecture style for designing networked applications. • REST is an architecture style for designing networked applications. The idea is that, rather than using complex mechanisms such as CORBA, RPC or SOAP to connect between machines, simple HTTP is used to make calls between machines. 18
  • 19. REST demo • JSONPlaceholder: https://jsonplaceholder.typicode.com/ • National Digital Forecast Database (NDFD) REST Web Service: http://graphical.weather.gov/xml/rest.php • Narodowy Bank Polski: http://api.nbp.pl/en.html 19
  • 20. REST • Endpoint • Resource • Methods (Post/Get/…) • Media type for the data (JSON, XML) 20
  • 21. CRUD CRUD • Create • Read • Update • Delete HTTP • Post • Get • Put • Delete 21
  • 22. Tools • Postman • SoapUI • Jmeter • REST Assured: https://github.com/rest-assured/rest-assured • Apache HttpClient: http://hc.apache.org • Async Http Client: https://github.com/AsyncHttpClient/async-http-client • RestTemplate https://docs.spring.io/spring/docs/current/javadoc- api/org/springframework/web/client/RestTemplate.html • … 22
  • 24. Postman • REST requests • SOAP requests +/- • Collections (test sets) • Scripts • Variables • Execute from command line (with Newman) • Integration with CI (with Newman) • JUnit reports (with Newman) • Web Service Mocking 24
  • 26. SoapUI • REST requests • SOAP requests • Tests • Test suits • Scripts • Variables • Execute from command line • Integration with CI • Integration with Maven • JUnit reports • Web Service Mocking 26
  • 29. More details • Postman docs: https://www.getpostman.com/docs/ • Scripts in Postman: https://www.getpostman.com/docs/postman/scripts/intro_to_scripts • Structuring and Running Tests (SoapUI): https://www.soapui.org/Functional-Testing/structuring- and-running-tests.html • Getting Started with REST Testing in SoapUI: https://www.soapui.org/rest-testing/getting- started.html • Newman: https://github.com/postmanlabs/newman • JSON Formatter & Validator: https://jsonformatter.curiousconcept.com/ • JSONLint - The JSON Validator: http://jsonlint.com/ 29
  • 30. WSDL • Web Services Description Language (WSDL, pronounced 'wiz-dul') is an XML-based language that is used for describing the functionality offered by a Web service. A WSDL description of a web service (also referred to as a WSDL file) provides a machine-readable description of how the service can be called, what parameters it expects and what data structures it returns. WSDL stands for Web Services Description Language • WSDL is used to describe web services • WSDL is written in XML • WSDL is a W3C recommendation 30
  • 31. WSDL parts • Data types definition (types) – the definition of sent and received XML service messages. • Data elements (message) – message used by web-service. • Abstract operations (portType) – the list of operations that can be performed with messages. • Service binding (binding) – the way the message will be delivered 31
  • 32. WSDL examples • ISBN Test: http://webservices.daehosting.com/services/isbnservice.wso?WSDL • Country Information: http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL • Number Conversion: http://www.dataaccess.com/webservicesserver/numberconversion.wso?WSDL • Bankleitzahlen Service: http://www.thomas-bayer.com/axis2/services/BLZService?wsdl • National Digital Forecast Database (NDFD) SOAP Web Service: http://graphical.weather.gov/xml/ 32
  • 33. SOAP • SOAP stands for Simple Object Access Protocol • SOAP is an application communication protocol • SOAP is a format for sending and receiving messages • SOAP is platform independent • SOAP is based on XML • SOAP is a W3C recommendation 33
  • 36. Tools • Postman • SoapUI • Axis: http://axis.apache.org/axis2/java/core/ • REST Assured: https://github.com/rest-assured/rest-assured • Apache HttpClient: http://hc.apache.org • Async Http Client: https://github.com/AsyncHttpClient/async-http-client • RestTemplate https://docs.spring.io/spring/docs/current/javadoc- api/org/springframework/web/client/RestTemplate.html • … 36
  • 37. More details • w3schools about SOAP: http://www.w3schools.com/xml/xml_soap.asp • w3schools about WSDL: http://www.w3schools.com/xml/xml_wsdl.asp • SoapUI: https://www.soapui.org/downloads/soapui/alternate-platforms.html • Your First SoapUI Project: https://www.soapui.org/getting-started/your-first-soapui-project.html 37
  • 38. Possible task • Create a project against any weather API. For example you can take NIST SOAP or REST service. Get temperature for San Francisco at 9 a.m. on the day of your choice. Add assertion if the temperature is grater than 0. 38
  • 40. Project file • Project data are stored in separate xmls files 40
  • 41. Properties • Project, TestSuite and TestCase have properties 41
  • 43. Properties Transfer • Transferring Property Values: https://www.soapui.org/functional-testing/properties/transferring- properties.html 43
  • 44. Property Expansion • ${#Scope#Property-name[#xpath-expression]} • ${#Project#Property-name}refers to a Project Property • ${#TestSuite#Property-name} refers to a TestSuite Property • ${#TestCase#Property-name} refers to a TestCase Property • ${TestStep-name#Property-name} refers to a property in a named TestStep. 44
  • 45. Assertions (Property Content) • Contains • Not Contains • JsonPath Count • JsonPath Existance Match • JsonPath Match • JsonPath RegEx Match • XPath Match • XQuery Math 45
  • 50. Assertions (Compliance, Status and Standarts) • HTTP Download all resource • Invalid HTTP Status Codes • Not SOAP Fault • Schema Compliance • SOAP Fault • SOAP Request • SOAP Response • Valid HTTP Status Codes • WS-Addressing Request • WS-Addressing Response • WS-Security Status 50
  • 53. Other assertions • SLA • JMS • JDBC • Security 53
  • 56. Setup/TearDown scripts • Suite Setup/TearDown • TestCase Setup/TearDown 56
  • 63. More details (Groovy) • Groovy Documentation: http://groovy-lang.org/documentation.html • Groovy JDK API Documentation: http://groovy-lang.org/gdk.html • SoapUI Tips & Tricks: https://www.soapui.org/scripting-properties/tips-tricks.html • 10 Groovy scripts on your finger tips – soapUI: https://learnsoapui.wordpress.com/2011/07/17/10- groovy-scripts-on-your-finger-tips-soapui/ • SoapUI Groovy: Slurping JSON in Script Assertions: https://thetestsuite.wordpress.com/2013/09/30/soapui-groovy-slurping-json-in-script-assertions/ • XML Parsing in soapUI: http://www.robert-nemet.com/2011/11/groovy-xml-parsing-in-soapui.html 63
  • 65. TestRunner (options) • ..SoapUI-5.2.1bintestrunner.bat • testrunner.bat -s"TestSuite 1" -r -j D:REST-Project-1-soapui-project.xml -f D:SoapUI-5.2.1report • a : Turns on exporting of all test results, not only errors • c : The TestCase to run, used to narrow down the tests to run • e : The endpoint to use when invoking test-requests, overrides the endpoint set in the project file • f : Specifies the root folder to which test results should be exported • j : Turns on exporting of JUnit-compatible reports, see below • P : Sets project property with name=value, e.g. -Pendpoint=Value1 -PsomeOtherProperty=value2 • s : The TestSuite to run, used to narrow down the tests to run 65
  • 66. SoapUI logs • By default in ..SoapUI-5.2.1bin • soapui-log4j.xml • soapui.log • soapui-errors.log • global-groovy.log 66
  • 67. Authorization • Steps to run Twitter API with SoapUI: http://acodediary.com/twitter-api-with-soapui/ 67
  • 71. Integration with Maven (project structure) • To execute project run command: mvn integration-test 71
  • 72. Integration with Maven (project structure) 72
  • 73. Integration with Maven (execution result) 73
  • 74. Integration with Maven (pom.xml) 74
  • 75. Integration with Maven (pom.xml) 75
  • 76. Integration with Maven (extensions) • Put additional jars into ext folder • Or add new module to the project 76
  • 77. Listeners • Create my-listeners.xml file in SoapUI-5.2.1binlisteners • Create MyListener.java, compile it in jar file and put in SoapUI-5.2.1binext • Create a directory build • Run java compilation from the command line: • javac -cp soapui-5.2.1.jar com/dataart/api/listeners/MyListener.java -d ./build • Go to the build folder (cd build) and create a jar • jar cvf YourJar.jar * 77
  • 80. More details • Rupert Anderson SoapUI Cookbook • Charitha Kankanamge Web Services Testing with soapUI 80
  • 81. More details • JSONPath - XPath for JSON: http://goessner.net/articles/JsonPath/ • Running Functional Tests (TestRunner): https://www.soapui.org/test-automation/running-functional- tests.html • SoapUI source code: https://github.com/SmartBear/soapui • SoapUI and Maven: https://www.soapui.org/test-automation/maven/maven-2-x.html • Source code in SoapUI maven: http://stackoverflow.com/questions/30320647/source-code-in- soapui-maven • Extending soapU: https://www.soapui.org/extension-plugins/old-style-extensions/developing-old- style-extensions.html • SoapUI JavaDoc: https://www.soapui.org/apidocs/allclasses-noframe.html 81
  • 82. More details • Custom report: https://github.com/a-oleynik/SoapUI/blob/master/CustomReport.groovy • Maven project with SoapUI example: https://github.com/a-oleynik/SoapUI/tree/master/api-test • Listener code example: https://github.com/a-oleynik/SoapUI/tree/master/Listener 82
  • 83. Possible task • Create custom report into an xml file. • Create a Data Driven test and read data from excel file. • Create a Maven project for your SoapUI project. Set the project up and execute it from the command line. 83