Front-end tests were initially planned for this project. But that doesn't mean they won't be written in the future. The decision was that for a small project, where at the moment there's only me as a dev, with a relatively small codebase, it would be somewhat unproductive to implement front-end tests. In larger codebases, front-end test writing becomes necessary, where the team is large and the system has high demand. However, for the beginning of this project, I choose to follow the MVP strategy because if I added too many features/code, I would naturally end up giving up on the project as it would become increasingly difficult to maintain.
Now, regarding back-end tests, this project has the two main types that I consider essential: integration tests and unit tests. Other types of tests in this small project would end up being redundant and unproductive. What is tested includes:
Repository tests, where we verify if the HQL/SQL queries work as they should. In this case, we check both success and failure cases. Currently, repository tests are not very useful because the HQL/SQL codebases are simple. However, as we will soon have more complex queries, these tests will be very useful. Repository tests involve testing queries from the codebase, and all queries are for the PostgreSQL RDBMS. These tests are then conducted with H2, which is an in-memory relational database, perfect for repository tests.
Exception tests, where system exceptions are tested, including validation exceptions. These tests mostly involve service exception testing, which is where the business logic resides. Therefore, they are unit tests that use mocks. However, some specific exception tests cannot be tested with mocks, such as validation tests done by Jakarta.Validation. The vast majority of validations in this system are done with Jakarta.Validation. However, it is used in the controller, which is where the API endpoints are located. Therefore, it is necessary for Jakarta.Validation exception tests to be integration tests, and in the case of this project, TestRestTemplate is used for these integration tests.
Success case tests are the simplest. I just want to ensure that when I send a certain input, the program works and continues to work, unlike exception tests where sending an input is expected to result in an exception. These success tests are only integration tests (with TestRestTemplate), where an input is sent to an endpoint, and it is expected that everything goes well.
Protect code base with tests
Tests are what keep your project alive for years.
Front-end tests were initially planned for this project. But that doesn't mean they won't be written in the future. The decision was that for a small project, where at the moment there's only me as a dev, with a relatively small codebase, it would be somewhat unproductive to implement front-end tests. In larger codebases, front-end test writing becomes necessary, where the team is large and the system has high demand. However, for the beginning of this project, I choose to follow the MVP strategy because if I added too many features/code, I would naturally end up giving up on the project as it would become increasingly difficult to maintain.
Now, regarding back-end tests, this project has the two main types that I consider essential: integration tests and unit tests. Other types of tests in this small project would end up being redundant and unproductive. What is tested includes:
13