I'm using Cobertura to calculate code/branch coverage for a Java project with JUnit test cases. I know 100% coverage does not tell how good the code is, but at the moment it's 6%. Branch coverage is 1%. My intuition says branch coverage is probably more important, due to the decision making nature of this project. As this is my only big project at the moment I have no experience in proper values for code/branch coverage aims.
I believe branch coverage is very important in this application, so I set the required value to 100%. I've defined the code coverage threshold to 80%.
Also what factor does code complexity for these values?
I am probably emphasising too much on numbers, but I'd like to hear about experience from other people. I'm aware these values are dependant on the project nature, but are there some general pointers/articles/personal experience I can refer to?
When I measured branch coverage produced by manual tests used for functional testing I got ~65%
Also look at What is a reasonable code coverage % for unit tests (and why)?
I'd like to hear about experience from other people.
I wrote a library with several thousands lines of code, and a coverage suite that was longer than the library itself. At 99.98%, I covered every single line except one: the method came from a legacy project, and I did not know how to construct a test case that would hit that line. When my library went into production, the very first bug report was caused by that single untested line.
My take-home lesson from that project was that the lines you don't know how to hit are the most dangerous. If your project is decision-intensive, it's in your best interest to get 100% coverage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With