3 ms·
I think your grammar is excellent and would never have guessed that English is not your native language. Code coverage is a good metric to get people to start
by bjourne 4y ago
I think your grammar is excellent and would never have guessed that English is not your native language.
Code coverage is a good metric to get people to start writing tests, but not a good metric to focus on. People may feel encouraged when their tests increase coverage from say, say 20% to 25%, so they write more tests. Though increasing coverage is not the end goal. For example, in Java you have setters and getters and writing tests for such methods just to increase coverage is useless busywork.
Instead, the goal is for tests to prevent bugs from sneaking into the software. Since many bugs only manifest themselves in strange special cases, tests that prevent such bugs must trigger those special cases. Suppose the website crashes if two users who share the same ip refreshes the page at a special stage in the signup flow. A test to prevent that bug must setup the same circumstances and emulate the same user interactions. Before the bug is fixed the test will fail, afterwards it will succeed. Such tests are incredibly useful but also takes lots of effort to write.