Thanks Pawel,
I believe what you’re seeing is intentional - it’s reporting on unit coverage. If you look at our Testing Guide we have a number of different kinds of tests. Somewhere in that stack of different types of tests we might have a test which “covers”
some line of code, but which isn’t included in the Sonar metric. This is the right thing to do when that test is not a unit test. Unit tests in the testing pyramid should be our go to type of test. As we’ve discussed at length here and in various calls,
we should have the most of these types of tests.
When the only logic we have is in controllers, that’s potentially concerning as we generally want business logic in domain classes. When those controllers have logic, and that logic is not covered by a unit test, only some other type of test
(such as an integration test), that’s a red flag, and Sonar is helping us identify that.
We want business logic to be unit tested. We want other types of tests as well, such as integration tests and contract tests, however our go to one metric view of testing reflecting on a healthy code-base is good unit test coverage.
As for the utility classes, I believe developers have not added to that due to those utility classes being Spring dependent. Our services have different versions of Spring Boot, and there is a concern of unforeseen coupling between those services
if we have a shared dependency (library) that has a basis in one particular spring version. I’m open to suggestions for reducing duplication that solves the dependency concern. In the meantime, we should certainly be copying tests for a utility class if
we’re already copying the utility class.
Best,
Josh