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.

What do you need to test API's?

6 views

Published on

Small presentation I did on Lisboa Quality Talks about tools to tackle three points that are common to all web API tests.

Published in: Software
  • Be the first to comment

  • Be the first to like this

What do you need to test API's?

  1. 1. What do you need to test API's? Geraldo Augusto Massahud Rodrigues dos Santos massahud@gmail.com https://www.linkedin.com/in/massahud
  2. 2. Web systems today
  3. 3. API GW External Service Client
  4. 4. API GW External Service Client Not tested by integration tests
  5. 5. API GW External Service Client Not tested by integration tests Each service integration test tests only its direct interactions
  6. 6. API Test API External Service Test
  7. 7. API Test API External Service Test Why don't we test internal messages or databases?
  8. 8. API Test API External Service Test Why don't we test internal messages or databases? Because if we do that it is harder to make changes on the internal microservice architecture.
  9. 9. API Test API External Service Test
  10. 10. API Test API External Service Test DIRECT interactions
  11. 11. API Test API External Service Test DIRECT interactions INDIRECT interactions
  12. 12. API Test API External Service Test DIRECT interactions INDIRECT interactions Asyncronous state changes and interactions
  13. 13. DIRECT interactions
  14. 14. API Test API External Service Test
  15. 15. Request libraries Almost every language can make HTTP requests, and have many libraries that do that
  16. 16. Some libraries are made specifically for tests REST Assured is one of the most used and gives you much power REST Assured
  17. 17. REST Assured
  18. 18. API client layer API client Actions StepDefs Feature
  19. 19. { … } Request object marshall { … } Response object unmarshall SUT request response API Client layer
  20. 20. { … } Request object marshall { … } Response object unmarshall SUT request response API Client layer Depending on the library you can work directly with the library generic Response object, not needing a specific class.
  21. 21. OpenAPI/Swagger API specification standard Can be used to generate the API Layer You have information about the whole API Can be generated by the cloud platform's API Gateway
  22. 22. API client layer API client Actions StepDefs Feature Isolate API calls Deal with objects, not text Can be autogenerated
  23. 23. Bonus: when you have have your whole API machine readable
  24. 24. INDIRECT interactions
  25. 25. API Test API External Service Test
  26. 26. API Test API External Service Test Request is an output Response is an input
  27. 27. Use an existing external service Great for external services that change state Hard to configure to return specific responses (indirect inputs) Sometimes an existing external service does not exist (webhook)
  28. 28. Mock the external service
  29. 29. API Test API WireMockTest POST /__admin/mappings
  30. 30. Mock service Service running on cloud with default mappings Test code can also configure mappings on the fly with SDK
  31. 31. Asynchronous wait
  32. 32. Polling SUT or External/Mock service Test

×