I'm currently working on a Spring Boot CRUD RESTful API with an User entity that consists of two parameters : name and id. Its endpoints are :
- POST REQUEST IN /users - Create an user
- GET REQUEST IN /users/{id} - List a specific user by its id
- GET REQUEST IN /users - List all users
- PUT REQUEST IN /users/{id} - Update a specific user by its id
- DELETE REQUEST IN /users/{id} - Delete a specific user by its id
Each endpoint is built with a controller and a service to implement its logic.
I've already wrote unit tests for my controllers and services, now i'm trying to build integration tests to assert that my endpoints work properly as a group of components.
The way i'm thinking of doing this is by calling all endpoints through a series of steps :
- Create an user through the create endpoint endpoint called
testUserOneand an user calledtestUserTwoand assert that they were created - List all users through the list all users endpoint and assert that both users were listed
- Change name parameter of
testUserOnethrough the update endpoint and assert it was changed - Remove
testUserTwothrough the delete endpoint and assert it was removed - List all users through the list all users endpoint and assert that only
testUserOnewas listed with its updated name parameter - List
testUserOnethrough the list an specific user endpoint and assert it was listed with its updated name parameter
No mocking involved, all this will be done by calling the real repository and asserting that every operation was executed and every response checked with its expected value.
This is the way i'm thinking of approaching this endpoints integration test, since it's my first time doing this, i'm hoping for some tips and guidance from the Stack Overflow community. Thank you!
Aucun commentaire:
Enregistrer un commentaire