I’d like to expose a use case to hear recommendations from you.
We have a old monolith where it has been there for 8 years now. We are pushing an initiative to improve unit test coverage over NEW code. The thing is that when making refactors and improving the code, it drags old code to be analyzed by the sonar Scan.
We currently have 80% of unit test coverage as a threshold for new code and sometime it’s hard to get that one even making unit tests for new part of the code.
Is there any recommendation/configuration that can be done to make this easier to handle WITHOUT configuring a lower threshold?
I don’t think you’re going to conquer this with configuration.
Having worked in an old, untested monolith, I’m guessing you’re facing enormous classes with individual methods that are possibly hundreds of lines long, right? Any small functionality change drags you into needing to cover the whole method?
My advice is that each time you need to make a change, extract the functionality you’re updating into a (well named!) sub/helper method. That method you’ll be able to test thoroughly. The method call you sub-into the main method will be untested, but percentage-wise this should be a winning strategy.