|Think about Loose Coupling|
Re^5: too much testing?by leriksen (Curate)
|on Oct 03, 2005 at 06:35 UTC||Need Help??|
OK, so as to your question(s) - are you testing "too much"
I have strong opinions on this, based on years of writing code that has experienced jut about every failure mode imaginable.
I have a personal belief that you have tested enough when you feel you have exercised as much of the code as you reasonably can. I use Devel::Cover to tell me how much I haven't done, and use my experience and judgement to make informed decisions as to what tests I will add for the remains.
For example, do you need to test what your code does if read() fails ? If so, writing test cases to do this is a bit difficult, but if you need it, do it.
Devel::Cover isn't perfect, and sometimes it can be very difficult to work with - for example, it complains about my $class = ref($proto)||$proto; as having an untested path in most "reasonable" usages. You have to write a test that calls the constructor in a manner you would expect to see for a function-based module e.g. Module::new(), not Module->new()
If it is important to you, you help newbies who do "Module::new" by mistake.
If not, ignore the report of the untested path from D::C and move on.
As an aside, I wrote a meditation on what I had to go through to get a reasonably large body of modules to get to 100% coverage as reported by D::C - see Lessons learned from getting to 100% with Devel::Cover about my struggles and discoveries from doing a deep testing effort.
...reality must take precedence over public relations, for nature cannot be fooled. - R P Feynmann