🚦 junit-5-how-to 🚦
This is an example of JUnit-5 with Spring 🔆
- This is a sandbox to test JUnit 5 not a real project,
- There is a small part of DDD (Domain Drive Design) and CQRS (Command Query Responsibility Segregation) inside as well.
- The project is using SpringBoot thus is possible to iterate using an endpoint or command line interface.
- Let's cover 3 ways to interact with the application
- GET
- hello
curl http://host:port/hello
- products
curl http://host:port/products
- hello
- POST
curl -d '{"title":"my product title", "price":"10"}' -H "Content-Type: application/json" -X POST http://host:port/products
For any doubt, check out the video
- GET
- hello
curl http://host:port/hello
- products
curl http://host:port/products
- hello
* After the application starts a dirty menu will show and press 1 key to create a random product or 2 key to list all products.
````console
******** CLI MENU **************
* 1 - Create a random product *
* 2 - Print all products *
* exit - Turn off CLI MENU *
********************************
1
2
Product{id='5cac3c8f-342f-4c50-ac30-b404ef755e3a', title='4057b5da-2', price=7}
````
- Go to the project folder and execute the following commands:
mvn clean verify
docker build -t junit-5-how-to/with-spring .
docker run -it -p 8080:8080 junit-5-how-to/with-spring
If you have any issue with the port, change it.
Follow the video below for any doubt.
Luiz Gustavo Costa