| Maybe you are jumping to a conclusion too quickly. How do you know what was really going on? "He created a requirement that every developer commit two new tests to the code base every workday" seem a stupid requirement if you do not control the quality of the tests. The same big corporation I wrote above had a goal of 80% code coverage reported on dashboards. I saw people writing tests just to run lines of code, without effectively testing anything. Others people were "smarter" and completely excluded folders and modules in the codebase with low coverage from coverage testing. Code coverage percentage numbers on a dashboard are a risky business. They can give you a false sense of confidence. Because you can have 100% code coverage and be plagued by multitude of bugs if you do not test what the code is supposed to do. Code coverage helps to see where you have untested code and if it is very low (ex: less 50%) tells you that you need more tests. An high code coverage percentage is desirable but should not be a target. The real problem is again the culture. A culture where it is ok to have critical parts of the code not being tested. A large part of the solution here is helping people to understand the consequences of low code coverage.
For example collecting experiences and during retrospectives point out where tests saved the day or how a test may have saved the day so people can see how test may save them a lot of frustration. But again, when you give people a target and it is the only thing they care about, people find a way to hit it. |
> When I worked at a FAANG ~15 years ago, a new VP came in and heard, correctly, that our group didn't have enough automated tests.