code smell: tests/production LOC ratio
disclaimer: this reasoning assumes the project is striving for 100% production code coverage by unit tests.
As noted elsewhere, optimal lines of code (LOC) ratio for production code vs unit tests is about 1:1. I wonder, does significant deviation on either part indicate a code smell?
First, consider the case when the ratio is about 5:1. This could mean two things:
PS: May be a "design smell" is a more appropriate term here?
update: My post's arguments were completed thrashed at c2.com. I'm still trying to figure out how much I (dis-)agree with them.
As noted elsewhere, optimal lines of code (LOC) ratio for production code vs unit tests is about 1:1. I wonder, does significant deviation on either part indicate a code smell?
First, consider the case when the ratio is about 5:1. This could mean two things:
- Code coverage is poor (a good guess -- about 20-30%). No good, obviously.
- If code coverage is in 80-95%% range than we most probably have some flavour of acceptance (functional) tests not a canonical unit tests. Which is no good either.
- Elaborate setup code and/or a lot of stubs may indicate not well factored class hierarchy.
- Lengthy test cases for particular production methods can indicate a heavyweight class waiting for the Extract class refactoring to be applied.
PS: May be a "design smell" is a more appropriate term here?
update: My post's arguments were completed thrashed at c2.com. I'm still trying to figure out how much I (dis-)agree with them.

3 Comments:
Interesting blog. I have a free xml editor blog.
“We cannot live for ourselves alone. Our lives are connected by a thousand invisible threads, and along these sympathetic fibers, our actions run as causes and return to us as results.”
- Herman Melville
RSS is the way of the Future...
rss feed directory
Hi,
I found this new software:
http://www.best-blog-link-generator.com
This is perfect for free traffic, high ranking, backlinks etc.
Check it out!
You don't want to miss this one.
Post a Comment
<< Home