Is Spring Boot Unit Test Coverage with Integration tests only a bad practice?
I have recently come across a few codebases at work where the previous developers chose to reach the >80% coverage criteria by writing only integration tests with the @SpringBootTest annotation that brings up the whole Spring Context. The company I work for has its own "Spring Boot Wrapper", let's call it SBW, so when I received the project, SBW was at version 0, but had to be updated to version 2. Naturally, when upgrading, all the integration tests broke. The issue that I see here is that if the new dev can't make the old integration tests work, the test coverage drops dramatically because there were no unit tests for each classic architecture layer, like Service, Repository, etc. There were just tests for the controllers, because being integration tests that simulate a rest call, you automatically gain a lot of coverage with very little tests, because the execution of the endpoint is whole. I proceeded to create unit tests for each class as I had learned in previous jobs, but that made the task way longer than it should have been. That's why I'm posing this question, reaching >80% coverage using just integration tests feels like a bad practice because of scenarios like this.
I have recently come across a few codebases at work where the previous developers chose to reach the >80% coverage criteria by writing only integration tests with the @SpringBootTest annotation that brings up the whole Spring Context.
The company I work for has its own "Spring Boot Wrapper", let's call it SBW, so when I received the project, SBW was at version 0, but had to be updated to version 2. Naturally, when upgrading, all the integration tests broke.
The issue that I see here is that if the new dev can't make the old integration tests work, the test coverage drops dramatically because there were no unit tests for each classic architecture layer, like Service, Repository, etc. There were just tests for the controllers, because being integration tests that simulate a rest call, you automatically gain a lot of coverage with very little tests, because the execution of the endpoint is whole.
I proceeded to create unit tests for each class as I had learned in previous jobs, but that made the task way longer than it should have been.
That's why I'm posing this question, reaching >80% coverage using just integration tests feels like a bad practice because of scenarios like this.