How much should unit tests cover?

How much should unit tests cover?

The majority of developers utilise tools or IDE plugins to verify code coverage on components that have already been tested. The number of lines or blocks of code that are executed while the tests are running is known as code coverage.

Use code coverage as a guide to identify sections that have not been tested. Rather than imposing a coverage rule, it is preferable to understand why a code is not covered. Keeping track of the reason for the shortage is important discipline that allows you to balance your risks.

The majority of developers write unit tests for items that are easier to test. According to this wiki article, 20% of all code will execute for 80% of the time. Without a call graph to establish what needs to be tested the most, a code coverage study is useless. This indicates where your edge cases are most likely to occur. You could create a hundred tests just for those edges.