SlideShare a Scribd company logo
1 of 22
Wiremock
testing tool
Mayo, 2016
Índice
Introducción
Qué es wiremock
Para qué sirve
Uso en Java unit tests
Uso como standalone
Limitaciones
Introducción
Importancia de testing
Auge de microservicios REST
Importancia de aislar tests y controlar los
sistemas externos
Qué es wiremock
Hace los tests por mí.
Mockea los objetos que uso.
Mockea los servicios http que uso.
Open source.
Licencia: Apache Version 2.0
Qué es wiremock - fuentes
creador: Tom Akehurst (@tomakehurst)
http://www.tomakehurst.com/
https://github.com/tomakehurst
Wiremock
http://wiremock.org/ (mailing list)
https://github.com/tomakehurst/wiremock
Qué es wiremock - Para qué sirve
Uso rápido y fácil
Accesible para devs y QAs
Asegura una respuesta real
(jetty)
Aísla de la implementación a
testear
Tests unitarios
Tests de integración
Tests funcionales
...
Qué es wiremock - características
Escrito en Java
Corre como servlet, rule
de JUnit or standalone
fluent Java API
HTTP Json API
Proxy
Record req/response
Verify requests
Stateful behaviour
Simula fallos
Extensible
Qué es wiremock - Primer paso
Standalone: descargar jar
Maven:
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<version>2.0.10-beta</version>
<scope>test</scope>
</dependency>
Wiremock - Java
Fácil uso con Java
Try this code here
Wiremock - Java
Fácil uso con JUnit (Rule built-in)
Cada test, nuevo wiremock
Source code here
Wiremock - standalone
Descargar:
wiremock-1.58-standalone.jar
http://search.maven.org/#search|ga|1|wiremock-standalone
Run standalone
Todos los parámetros: http://wiremock.org/running-standalone.html
java -jar wiremock-1.58-standalone.jar
Wiremock - fluent Java API
Fácil de lectura
Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BYTry this code here
Wiremock - Http Json API
Útil para usarlo en standalone.
Para cualquier lenguaje.
● Listar mappings GET: /__admin
● Crear nuevo POST: /__admin/mappings/new
● Reset mappings POST: /__admin/mappings/reset
● Eliminar todos los mappings POST: /__admin/reset
● Shutdown wiremock POST: /__admin/shutdownIcons made by Freepik from www.flaticon.com is licensed by CC 3.0 BYSource code here
Wiremock - proxy
Proxy como un navegador (proxyBaseUrl)
Proxy-all: todas req se redirigen
Usar proxy opaco para salir a internet
Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY
Wiremock - record requests
Graba peticiones-respuestas http reales.
Standalone mode con los parámetros:
--record-mappings --proxy-all="https://github.com/"
Los archivos estarán en mappings y __files.
Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BYSource code here
Wiremock - stateful behaviour
Mock cuando se hayan ejecutado
ciertas peticiones
"scenarioName": "Example",
"requiredScenarioState": "Started",
"newScenarioState": "Step1",
Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BYSource code here
Wiremock - faults
Podemos simular fallos:
● Retrasos en la respuesta.
● Timeout.
● EMPTY_RESPONSE
● MALFORMED_RESPONSE_CHUNK
● RANDOM_DATA_THEN_CLOSE
Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BYSource code here
Modificar response dinámicamente.
Clase Java que extiende `ResponseTransformer`
Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY
Wiremock - extensible
Wiremock - limitaciones
Cuelgues en standalone (evitable con -no-request-journal)
https ← proxy → https (man-in-the-middle)
Eliminar un mapping individualmente
Puertos dinámicos evitan colisiones
Logs mejorables (v2 son mejores)
Business vector designed by Alekksall
Freepik.com
Wiremock - Logs
Añadir implementación slf4j. Ejemplo con log4j2
● Añadir classpath con jar de log4j2
● Comando java no permite -jar y -cp
● Ejemplo de comando:
https://github.com/jose-oc/learning-
wiremock/blob/master/standalone/start_wiremock_with_logs.sh
Wiremock - recursos
Los ejemplos mostrados los tienes disponibles en:
https://github.com/jose-oc/learning-wiremock
@_jose_oc
www.joseoc.es
Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY
Icons made by Google from www.flaticon.com is licensed by CC 3.0 BY
jose.ortiz@piksel.com
linkedin.com/in/joseoc
gracias

More Related Content

What's hot

Dev and Ops Collaboration and Awareness at Etsy and Flickr
Dev and Ops Collaboration and Awareness at Etsy and FlickrDev and Ops Collaboration and Awareness at Etsy and Flickr
Dev and Ops Collaboration and Awareness at Etsy and FlickrJohn Allspaw
 
TestNG Annotations in Selenium | Edureka
TestNG Annotations in Selenium | EdurekaTestNG Annotations in Selenium | Edureka
TestNG Annotations in Selenium | EdurekaEdureka!
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOPDzmitry Naskou
 
Apiドキュメンテーションツールを使いこなす【api blueprint編】
Apiドキュメンテーションツールを使いこなす【api blueprint編】Apiドキュメンテーションツールを使いこなす【api blueprint編】
Apiドキュメンテーションツールを使いこなす【api blueprint編】dcubeio
 
GitHub Actions with Node.js
GitHub Actions with Node.jsGitHub Actions with Node.js
GitHub Actions with Node.jsStefan Stölzle
 
Introduction To Git For Version Control Architecture And Common Commands Comp...
Introduction To Git For Version Control Architecture And Common Commands Comp...Introduction To Git For Version Control Architecture And Common Commands Comp...
Introduction To Git For Version Control Architecture And Common Commands Comp...SlideTeam
 
CICD Pipeline Using Github Actions
CICD Pipeline Using Github ActionsCICD Pipeline Using Github Actions
CICD Pipeline Using Github ActionsKumar Shìvam
 
Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKJosé Paumard
 
GitHub Actions in action
GitHub Actions in actionGitHub Actions in action
GitHub Actions in actionOleksii Holub
 
Karate for Complex Web-Service API Testing by Peter Thomas
Karate for Complex Web-Service API Testing by Peter ThomasKarate for Complex Web-Service API Testing by Peter Thomas
Karate for Complex Web-Service API Testing by Peter Thomasintuit_india
 
Java ORマッパー選定のポイント #jsug
Java ORマッパー選定のポイント #jsugJava ORマッパー選定のポイント #jsug
Java ORマッパー選定のポイント #jsugMasatoshi Tada
 
Karate - powerful and simple framework for REST API automation testing
Karate - powerful and simple framework for REST API automation testingKarate - powerful and simple framework for REST API automation testing
Karate - powerful and simple framework for REST API automation testingRoman Liubun
 
絶対落ちないアプリの作り方
絶対落ちないアプリの作り方絶対落ちないアプリの作り方
絶対落ちないアプリの作り方Fumihiko Shiroyama
 
Criando uma arquitetura para seus testes de API com RestAssured
Criando uma arquitetura para seus testes de API com RestAssuredCriando uma arquitetura para seus testes de API com RestAssured
Criando uma arquitetura para seus testes de API com RestAssuredElias Nogueira
 
Introduction to Java 11: Support and JVM Features #jjug
Introduction to Java 11: Support and JVM Features #jjugIntroduction to Java 11: Support and JVM Features #jjug
Introduction to Java 11: Support and JVM Features #jjugYuji Kubota
 

What's hot (20)

Dev and Ops Collaboration and Awareness at Etsy and Flickr
Dev and Ops Collaboration and Awareness at Etsy and FlickrDev and Ops Collaboration and Awareness at Etsy and Flickr
Dev and Ops Collaboration and Awareness at Etsy and Flickr
 
TestNG Annotations in Selenium | Edureka
TestNG Annotations in Selenium | EdurekaTestNG Annotations in Selenium | Edureka
TestNG Annotations in Selenium | Edureka
 
GitLab.pptx
GitLab.pptxGitLab.pptx
GitLab.pptx
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
 
Version control
Version controlVersion control
Version control
 
Apiドキュメンテーションツールを使いこなす【api blueprint編】
Apiドキュメンテーションツールを使いこなす【api blueprint編】Apiドキュメンテーションツールを使いこなす【api blueprint編】
Apiドキュメンテーションツールを使いこなす【api blueprint編】
 
GitHub Actions with Node.js
GitHub Actions with Node.jsGitHub Actions with Node.js
GitHub Actions with Node.js
 
Introduction To Git For Version Control Architecture And Common Commands Comp...
Introduction To Git For Version Control Architecture And Common Commands Comp...Introduction To Git For Version Control Architecture And Common Commands Comp...
Introduction To Git For Version Control Architecture And Common Commands Comp...
 
CICD Pipeline Using Github Actions
CICD Pipeline Using Github ActionsCICD Pipeline Using Github Actions
CICD Pipeline Using Github Actions
 
Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UK
 
GitHub Actions in action
GitHub Actions in actionGitHub Actions in action
GitHub Actions in action
 
Karate for Complex Web-Service API Testing by Peter Thomas
Karate for Complex Web-Service API Testing by Peter ThomasKarate for Complex Web-Service API Testing by Peter Thomas
Karate for Complex Web-Service API Testing by Peter Thomas
 
Sonarqube
SonarqubeSonarqube
Sonarqube
 
Feature toggles
Feature togglesFeature toggles
Feature toggles
 
Java ORマッパー選定のポイント #jsug
Java ORマッパー選定のポイント #jsugJava ORマッパー選定のポイント #jsug
Java ORマッパー選定のポイント #jsug
 
Karate - powerful and simple framework for REST API automation testing
Karate - powerful and simple framework for REST API automation testingKarate - powerful and simple framework for REST API automation testing
Karate - powerful and simple framework for REST API automation testing
 
絶対落ちないアプリの作り方
絶対落ちないアプリの作り方絶対落ちないアプリの作り方
絶対落ちないアプリの作り方
 
Criando uma arquitetura para seus testes de API com RestAssured
Criando uma arquitetura para seus testes de API com RestAssuredCriando uma arquitetura para seus testes de API com RestAssured
Criando uma arquitetura para seus testes de API com RestAssured
 
Introduction to Java 11: Support and JVM Features #jjug
Introduction to Java 11: Support and JVM Features #jjugIntroduction to Java 11: Support and JVM Features #jjug
Introduction to Java 11: Support and JVM Features #jjug
 
WebSocket / WebRTCの技術紹介
WebSocket / WebRTCの技術紹介WebSocket / WebRTCの技術紹介
WebSocket / WebRTCの技術紹介
 

Similar to Wiremock testing tool guide

Using Proxies To Secure Applications And More
Using Proxies To Secure Applications And MoreUsing Proxies To Secure Applications And More
Using Proxies To Secure Applications And MoreJosh Sokol
 
Keycloak Single Sign-On
Keycloak Single Sign-OnKeycloak Single Sign-On
Keycloak Single Sign-OnRavi Yasas
 
Pushing the web — WebSockets
Pushing the web — WebSocketsPushing the web — WebSockets
Pushing the web — WebSocketsRoland M
 
The Emergence of Choice in the .NET Ecosystem
The Emergence of Choice in the .NET EcosystemThe Emergence of Choice in the .NET Ecosystem
The Emergence of Choice in the .NET EcosystemJames Avery
 
TakeDownCon Rocket City: WebShells by Adrian Crenshaw
TakeDownCon Rocket City: WebShells by Adrian CrenshawTakeDownCon Rocket City: WebShells by Adrian Crenshaw
TakeDownCon Rocket City: WebShells by Adrian CrenshawEC-Council
 
44CON London 2015 - Going AUTH the Rails on a Crazy Train
44CON London 2015 - Going AUTH the Rails on a Crazy Train44CON London 2015 - Going AUTH the Rails on a Crazy Train
44CON London 2015 - Going AUTH the Rails on a Crazy Train44CON
 
Rohit yadav cloud stack internals
Rohit yadav   cloud stack internalsRohit yadav   cloud stack internals
Rohit yadav cloud stack internalsShapeBlue
 
Robot Framework Introduction & Sauce Labs Integration
Robot Framework Introduction & Sauce Labs IntegrationRobot Framework Introduction & Sauce Labs Integration
Robot Framework Introduction & Sauce Labs IntegrationSauce Labs
 
Genomic Computation at Scale with Serverless, StackStorm and Docker Swarm
Genomic Computation at Scale with Serverless, StackStorm and Docker SwarmGenomic Computation at Scale with Serverless, StackStorm and Docker Swarm
Genomic Computation at Scale with Serverless, StackStorm and Docker SwarmDmitri Zimine
 
Websockets on the JVM: Atmosphere to the rescue!
Websockets on the JVM: Atmosphere to the rescue!Websockets on the JVM: Atmosphere to the rescue!
Websockets on the JVM: Atmosphere to the rescue!jfarcand
 
Testing distributed systems in production
Testing distributed systems in productionTesting distributed systems in production
Testing distributed systems in productionPaul Bakker
 
C#Web Sec Oct27 2010 Final
C#Web Sec Oct27 2010 FinalC#Web Sec Oct27 2010 Final
C#Web Sec Oct27 2010 FinalRich Helton
 
Tornado Web Server Internals
Tornado Web Server InternalsTornado Web Server Internals
Tornado Web Server InternalsPraveen Gollakota
 
Not Only Streams for Akademia JLabs
Not Only Streams for Akademia JLabsNot Only Streams for Akademia JLabs
Not Only Streams for Akademia JLabsKonrad Malawski
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidenceJohn Congdon
 
Subgraph vega countermeasure2012
Subgraph vega countermeasure2012Subgraph vega countermeasure2012
Subgraph vega countermeasure2012David Mirza
 
Subgraph vega countermeasure2012
Subgraph vega countermeasure2012Subgraph vega countermeasure2012
Subgraph vega countermeasure2012David Mirza
 
Java Web Security Class
Java Web Security ClassJava Web Security Class
Java Web Security ClassRich Helton
 

Similar to Wiremock testing tool guide (20)

Using Proxies To Secure Applications And More
Using Proxies To Secure Applications And MoreUsing Proxies To Secure Applications And More
Using Proxies To Secure Applications And More
 
Keycloak Single Sign-On
Keycloak Single Sign-OnKeycloak Single Sign-On
Keycloak Single Sign-On
 
Pushing the web — WebSockets
Pushing the web — WebSocketsPushing the web — WebSockets
Pushing the web — WebSockets
 
The Emergence of Choice in the .NET Ecosystem
The Emergence of Choice in the .NET EcosystemThe Emergence of Choice in the .NET Ecosystem
The Emergence of Choice in the .NET Ecosystem
 
TakeDownCon Rocket City: WebShells by Adrian Crenshaw
TakeDownCon Rocket City: WebShells by Adrian CrenshawTakeDownCon Rocket City: WebShells by Adrian Crenshaw
TakeDownCon Rocket City: WebShells by Adrian Crenshaw
 
44CON London 2015 - Going AUTH the Rails on a Crazy Train
44CON London 2015 - Going AUTH the Rails on a Crazy Train44CON London 2015 - Going AUTH the Rails on a Crazy Train
44CON London 2015 - Going AUTH the Rails on a Crazy Train
 
Rohit yadav cloud stack internals
Rohit yadav   cloud stack internalsRohit yadav   cloud stack internals
Rohit yadav cloud stack internals
 
Robot Framework Introduction & Sauce Labs Integration
Robot Framework Introduction & Sauce Labs IntegrationRobot Framework Introduction & Sauce Labs Integration
Robot Framework Introduction & Sauce Labs Integration
 
Genomic Computation at Scale with Serverless, StackStorm and Docker Swarm
Genomic Computation at Scale with Serverless, StackStorm and Docker SwarmGenomic Computation at Scale with Serverless, StackStorm and Docker Swarm
Genomic Computation at Scale with Serverless, StackStorm and Docker Swarm
 
Power ai image-pipeline
Power ai image-pipelinePower ai image-pipeline
Power ai image-pipeline
 
Websockets on the JVM: Atmosphere to the rescue!
Websockets on the JVM: Atmosphere to the rescue!Websockets on the JVM: Atmosphere to the rescue!
Websockets on the JVM: Atmosphere to the rescue!
 
Testing distributed systems in production
Testing distributed systems in productionTesting distributed systems in production
Testing distributed systems in production
 
C#Web Sec Oct27 2010 Final
C#Web Sec Oct27 2010 FinalC#Web Sec Oct27 2010 Final
C#Web Sec Oct27 2010 Final
 
Tornado Web Server Internals
Tornado Web Server InternalsTornado Web Server Internals
Tornado Web Server Internals
 
bjhbj
bjhbjbjhbj
bjhbj
 
Not Only Streams for Akademia JLabs
Not Only Streams for Akademia JLabsNot Only Streams for Akademia JLabs
Not Only Streams for Akademia JLabs
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidence
 
Subgraph vega countermeasure2012
Subgraph vega countermeasure2012Subgraph vega countermeasure2012
Subgraph vega countermeasure2012
 
Subgraph vega countermeasure2012
Subgraph vega countermeasure2012Subgraph vega countermeasure2012
Subgraph vega countermeasure2012
 
Java Web Security Class
Java Web Security ClassJava Web Security Class
Java Web Security Class
 

Recently uploaded

Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 

Recently uploaded (20)

Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 

Wiremock testing tool guide

  • 2. Índice Introducción Qué es wiremock Para qué sirve Uso en Java unit tests Uso como standalone Limitaciones
  • 3. Introducción Importancia de testing Auge de microservicios REST Importancia de aislar tests y controlar los sistemas externos
  • 4. Qué es wiremock Hace los tests por mí. Mockea los objetos que uso. Mockea los servicios http que uso. Open source. Licencia: Apache Version 2.0
  • 5. Qué es wiremock - fuentes creador: Tom Akehurst (@tomakehurst) http://www.tomakehurst.com/ https://github.com/tomakehurst Wiremock http://wiremock.org/ (mailing list) https://github.com/tomakehurst/wiremock
  • 6. Qué es wiremock - Para qué sirve Uso rápido y fácil Accesible para devs y QAs Asegura una respuesta real (jetty) Aísla de la implementación a testear Tests unitarios Tests de integración Tests funcionales ...
  • 7. Qué es wiremock - características Escrito en Java Corre como servlet, rule de JUnit or standalone fluent Java API HTTP Json API Proxy Record req/response Verify requests Stateful behaviour Simula fallos Extensible
  • 8. Qué es wiremock - Primer paso Standalone: descargar jar Maven: <dependency> <groupId>com.github.tomakehurst</groupId> <artifactId>wiremock</artifactId> <version>2.0.10-beta</version> <scope>test</scope> </dependency>
  • 9. Wiremock - Java Fácil uso con Java Try this code here
  • 10. Wiremock - Java Fácil uso con JUnit (Rule built-in) Cada test, nuevo wiremock Source code here
  • 11. Wiremock - standalone Descargar: wiremock-1.58-standalone.jar http://search.maven.org/#search|ga|1|wiremock-standalone Run standalone Todos los parámetros: http://wiremock.org/running-standalone.html java -jar wiremock-1.58-standalone.jar
  • 12. Wiremock - fluent Java API Fácil de lectura Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BYTry this code here
  • 13. Wiremock - Http Json API Útil para usarlo en standalone. Para cualquier lenguaje. ● Listar mappings GET: /__admin ● Crear nuevo POST: /__admin/mappings/new ● Reset mappings POST: /__admin/mappings/reset ● Eliminar todos los mappings POST: /__admin/reset ● Shutdown wiremock POST: /__admin/shutdownIcons made by Freepik from www.flaticon.com is licensed by CC 3.0 BYSource code here
  • 14. Wiremock - proxy Proxy como un navegador (proxyBaseUrl) Proxy-all: todas req se redirigen Usar proxy opaco para salir a internet Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY
  • 15. Wiremock - record requests Graba peticiones-respuestas http reales. Standalone mode con los parámetros: --record-mappings --proxy-all="https://github.com/" Los archivos estarán en mappings y __files. Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BYSource code here
  • 16. Wiremock - stateful behaviour Mock cuando se hayan ejecutado ciertas peticiones "scenarioName": "Example", "requiredScenarioState": "Started", "newScenarioState": "Step1", Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BYSource code here
  • 17. Wiremock - faults Podemos simular fallos: ● Retrasos en la respuesta. ● Timeout. ● EMPTY_RESPONSE ● MALFORMED_RESPONSE_CHUNK ● RANDOM_DATA_THEN_CLOSE Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BYSource code here
  • 18. Modificar response dinámicamente. Clase Java que extiende `ResponseTransformer` Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY Wiremock - extensible
  • 19. Wiremock - limitaciones Cuelgues en standalone (evitable con -no-request-journal) https ← proxy → https (man-in-the-middle) Eliminar un mapping individualmente Puertos dinámicos evitan colisiones Logs mejorables (v2 son mejores) Business vector designed by Alekksall Freepik.com
  • 20. Wiremock - Logs Añadir implementación slf4j. Ejemplo con log4j2 ● Añadir classpath con jar de log4j2 ● Comando java no permite -jar y -cp ● Ejemplo de comando: https://github.com/jose-oc/learning- wiremock/blob/master/standalone/start_wiremock_with_logs.sh
  • 21. Wiremock - recursos Los ejemplos mostrados los tienes disponibles en: https://github.com/jose-oc/learning-wiremock @_jose_oc www.joseoc.es Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY Icons made by Google from www.flaticon.com is licensed by CC 3.0 BY jose.ortiz@piksel.com linkedin.com/in/joseoc

Editor's Notes

  1. Presentación de esta herramienta y cómo la estamos usando actualmente.
  2. Cambio en la arquitectura de sistemas: incremento en el número de microservicios http (propios y de terceros) Por el auge de microservicios Q: ¿quién hace tests?
  3. Stub: it makes the input deteministic. Mock: it makes the output deterministic. ESto significa que puedo aislar el sistema que quiero testear de servicios http externos al mismo y de los que hago uso.
  4. Es una herramienta para mockear una respuesta. Podemos usarla para el tipo de test que nos interese.
  5. Verify
  6. También funciona con el modo proxy as browser
  7. No se puede eliminar un mapping individualmente Usándolo en modo standalone durante un tiempo prolongado requiere reinicio (evitable con -no-request-journal) No puede actuar como proxy entre sitios https (man-in-the-middle) Usa puertos dinámicos si tus tests pueden correr a la vez en la misma máquina. Logs mejorables (v2 son mejores)