Skip to content

Instantly share code, notes, and snippets.

@eliasnogueira
Last active September 11, 2022 17:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eliasnogueira/cac02e82931730ba40ef2de3da48faa0 to your computer and use it in GitHub Desktop.
Save eliasnogueira/cac02e82931730ba40ef2de3da48faa0 to your computer and use it in GitHub Desktop.
How to test complex API integrations

Title

How to test complex API integrations

Elevator pitch

Testing microservices is a day-by-day activity for any software engineer and is highly required to deliver bug-free services. Most of them create tests that can be seen only inside de microservice project which are unit and integration, whereas others cannot have the benefit to reuse. Applying the approach proposed in this presentation will enable you to create an approach to add more coverage, speed up the testing process, and enable e2e tests across different APIs.

Description

In the world of microservices, one of the challenges is to guarantee that the integrations we have for internal and external services are working without mocks. Normally we do unit and integration tests, but it's not sufficient to cover scenarios the customer might do in the real world.

This presentation will show how to extend the API test coverage through functional and end-to-end tests, using Rest-Assured, some design and test patterns, and a pipeline strategy to make sure the integration between different microservices can work as expected. A possible project structure as test client and project will be shown to make easier the test reuse among different microservices (and maybe different teams).

Tools and techniques

Tools

The main test tool used in this presentation is Rest-Assured, a well-known API test library for Java applications. JUnit 5 will be used as the main test engine. Also, different tools like Java-Faker and Owner will be used to manage, respectively, fake data generation and manage property files.

Patterns

There will be two main testing patterns in use: the Base Test and the Data Factory. The Base Test will add the ability to change the common methods based on different test suites combinations. The Data Factory will generate different types of data, necessary to use for different test scenarios.

Techniques

The presentation will show an agnostic approach to implementing a pipeline as a code but show how we can break it down into different steps in the test verification phase to have a reliable pipeline ready for a Continuous Delivery process.

Takeaways

  • How to extend the API test coverage by applying functional and end-to-end tests
  • Learn testing patterns to apply in different projects
  • Full code example of different project implementation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment