to develop their quality mindset and deliver bug-free software so they become top-level engineers and get hired for the best positions in the market. 🏢 Backbase 👨💻 Principal Software Engineer 📍 Utrecht, the Netherlands 🌐 eliasnogueira.com 🐦 @eliasnogueira bit.ly/eliasnogueira
API API API Each API must have its unit tests and integration. Integration Tests* done! * API Tests running in an integration layer with or without mocks
is self-tested unit -> integration -> functional Search Flight selection Payment Confirmation Valid dates Invalid return date No flights found API API API API
is self-tested e2e: buy a round-trip flight Search Flight selection Payment Confirmation Select valid dates API API API API Select a flight with seats available Make a payment with valid data Successful notification E2E Scenario
necessary logic to make the requests as: ◦ Exception return ◦ Transport Objects ◦ Request call ◦ Customizations for validations ◦ Pointing settings (URI, base path, port)
methods of using the API we created in the client project, creating the testing logic and validating the results. In summary, all tests are created here!
to the microservice, whether the calls were successful or simulating exceptions. Project containing tests for the microservice, testing its functionality and dependencies with other microservices. Code and libraries common to clients such as URL definitions, authentication, and any other shared code. Code and libraries common to tests such as testing data, support functions, or any common code related to tests.
to make the requests as: RESTRICTIONS GET /api/v1/restricrions/{cpf} GET /api/v2/restricrions/{cpf} Constraint Query API SIMULATIONS GET /api/v1/simulations/ GET /api/v1/simulations/{cpf} POST /api/v1/simulations/ PUT /api/v1/simulations/{cpf} DELETE /api/v1/simulations/{cpf} Credit Simulation API
calls from each HTTP method CLIENT RESTRICTIONS GET /api/v1/restricrions/{cpf} Constaint Query API Client Method - find CPF Method - find CPF and return an exception
Client API Method – find all simulations Method – find a simulation by a given CPF Method – find a simulation by a given CPF and return not found Method – submit a simulation Method – submit a simulation and return unprocessable entity Method – submit a simulation and return conflict Methods will be created to simulate all possible calls from each HTTP method Client’s implementation
submit a simulation A test method will be created for one or more use of the methods on the client Test implementation TEST SIMULATIONS should create a successful simulation - Test Credit Simulation Test Project
return unprocessable entity A test method will be created for one or more use of the methods on the client TEST SIMULATIONS should show an error regarding an attribute not sent in the request - Test - Test Credit Simulation Client API Credit Simulation Test Project Test implementation Method – submit a simulation should create a successful simulation
return conflict TEST SIMULATIONS should show conflict when CPF already exists - Test Credit Simulation Client API Credit Simulation Test Project A test method will be created for one or more use of the methods on the client Test implementation Method – submit a simulation and return unprocessable entity should show an error regarding an attribute not sent in the request - Test - Test Method – submit a simulation should create a successful simulation
• We must add the client dependency in the test <dependency> <groupId>com.eliasnogueira</groupId> <artifactId>simulations-client</artifactId> <version>1.2.5</version> </dependency> "devDependencies": { "@eliasnogueira/simulations-client": ”1.2.5", } Java + Maven example Typescript + Node example
client with the microservice version Just as the microservice evolves the client and the test evolve. Adding a changelog with the association of the client version with the microservice version can help fix bugs. Also tags helps if you would like to track the evolution.
the *-test project could be moved to the integration layer ◦ they will provide you faster feedback • The *-test projects must have the functional/e2e tests using different APIs we depends on
a microservice in isolation (functional test) ◦ test a microservice and its dependencies (e2e) • We’ve modularized the creation of projects ◦ client: the entire API call for a microservice ◦ test: test project using the microservice client ◦ commons: client codes and libraries ◦ parent: test code and libraries
after you clone it, you must configure the GitHub Packages in your pom.xml file. You can find the example here: https://docs.github.com/en/packages/working-with-a-github- packages-registry/working-with-the-apache-maven-registry Replace the OWNER by eliasnogueira