This is a demo Spring boot app: it only contains 1 controller with a few endpoints. Data is stored in a PostgreSQL database.
Unit testing example provided for one class, a service. Dependencies (the database) are mocked out.
Test suite is not complete, but the other classes could be tested similarly.
Integration tests launch the entire app. During these tests and actual Postgres DB is launched in Docker, which is then destroyed after the tests end. This functionality is provided by the Testcontainers framework.
MockMvc
is used to make HTTP requests to the application.
Test suite is not complete, but the other endpoints could be tested similarly.
Sample GitHub Actions pipeline is provided which
runs the unit and integration tests, with Gradle. This pipeline can be triggered
manually, or by pushing source code changes to master
.