Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Service Testing. WTF Does This API Do

36 views

Published on

Los servicios Rest se están comiendo al mundo poco a poco y automatizar las pruebas a estos servicios, sí que podrá darnos tranquilidad.

Published in: Software
  • Be the first to comment

  • Be the first to like this

Service Testing. WTF Does This API Do

  1. 1. TAE week - 2018 Service testing WTF Does This API Do? Diego Montoya Lopera Diego Berdugo Castañeda Mauricio Rodriguez
  2. 2. Background Web services (ReST) API Testing Black box API Testing REST Assured framework White box API Testing JOOQ - Framework AGENDA What to expect today
  3. 3. What is a web service? A Web service is a software system designed to support interoperable machine-to-machine interaction over a network. A web service is not targeted at humans but rather at other programs. Is not tied to any one operating system or programming language ¿? Background | Web services
  4. 4. Source code, data repository, config files, servers, network infrastructure, business logic, Algorithm, Database, SQL NoSQL... Web services Background | Web services Device or systemWEB SERVICE End userApplication Mobile Device. iOS, Android Desktop TV & wearables Laptop Another App
  5. 5. ReST: “REpresentational State Transfer” Systems integration. Data sharing. Don’t reinvent the wheel. Used formats for data transfer. Client server. Uses HTTP methods. Uses HTTP message codes. ReST web services Background | Web services Resources Based Usages XML and JSON HTTP Based
  6. 6. JSON FORMAT Background | Web services { "title": "Deadpool", "releaseDate": "2016-02-08", "director": "Tim Miller", "starring": ["Ryan Reynols”, “Morena Baccarin”,”Skrein"] }
  7. 7. HTTP Background | Web services GET: Obtain information POST: Create a resource PUT: Update existing resource DELETE: Delete a resource PATCH: Partially update a resource 1xx: Informational 2xx: Success 3xx: Redirection 4xx: Client Error (404: Not found) 5xx: Server Error HTTPMethods HTTPCodes
  8. 8. Background | API testing API Testing Exploratory Component Unit Integration End to end https://martinfowler.com/articles/microservice-testing/#conclusion-test-pyramid
  9. 9. End to End Acceptance test Black Box* Data Driven Load test Not focused on final user interactions Performance Test What is API Testing? Background | API testing
  10. 10. Black box testing
  11. 11. Counter example (using java) Black box API testing | example the movies API exposed I search the movie: Avengers I expect to get: Response code: 200 “Robert Downey Jr., Chris Evans, Scarlett Johansson” in the list of actors 2012 as the release year Sci-Fi as the genre Given: When: Then: a b
  12. 12. Black box API testing | Intro Black box testing tools
  13. 13. Black box API testing | REST Assured
  14. 14. What is it? Installation REST Assured is a Java library that provides a domain-specific language (DSL) for writing powerful, maintainable tests for RESTful APIs. REST Assured is open source, which makes it easily accessible to everyone, therefore, becoming one of the most popular REST API validation tools. REST Assured Maven Gradle Black box API testing | REST Assured
  15. 15. REST Assured examples EXAMPLES GET User with RestAssured. POST Create new user, validating the id and creation_date returned by the API POST Create entity, GET: the new id and make a new API request to get the info. DELETE the newly created entity Performance GET all the movies. Black box API testing | REST Assured
  16. 16. Let’s code
  17. 17. Counter example REST Assured So… Why should I use REST Assured? Black box API testing | REST Assured
  18. 18. White box testing
  19. 19. What is it? jOOQ generates Java code from your database and lets you build type safe SQL queries through its fluent API JOOQ White box API testing | JOOQ
  20. 20. Why use it? ● Database First ● SQL centered ● Typesafe SQL ● Multi-Tenancy ● Standardization ● Query Lifecycle ● Procedures ● Code Generation ● Active Records JOOQ White box API testing | JOOQ
  21. 21. Editions JOOQ Download ZIP Maven White box API testing | JOOQ Installation Free - Open Source Paid - Express, Professional, Enterprise
  22. 22. Let’s code EXAMPLES GET: comparison between the DB records and the API entities POST: Create an entity and validate the insert GET: the new id and query the DB. DELETE: the entity create Data driven test: Get multiple DB records and for each make request to the API validating the info White box API testing | JOOQ
  23. 23. Command Line Generation Tool Maven JOOQ White box API testing | JOOQ Eclipse
  24. 24. API Testing Recommendations ① Write as few end-to-end tests as possible ② Focus on personas and user journeys ③ Choose your ends wisely ④ Rely on infrastructure-as-code for repeatability ⑤ Make tests data-independent Final thoughts https://martinfowler.com/articles/microservice-testing/#testing-end-to-end-tips
  25. 25. ¿Questions?

×