Search code examples
testingcode-coveragecobertura

Code coverage / branch coverage recommended values


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?


Solution

  • 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)?