note
leriksen
OK, so as to your question(s) - are you testing "too much"<p>
I have strong opinions on this, based on years of writing code that has experienced jut about every failure mode imaginable.<p>
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 [cpan://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.<p>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.<br>Otherwise, code and test on the assumption "read() will never fail" and move on.<p>[cpan://Devel::Cover] isn't perfect, and sometimes it can be very difficult to work with - for example, it complains about <code>my $class = ref($proto)||$proto;</code> 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. <code>Module::new()</code>, not <code>Module->new()</code><br>So you need to ask yourself "is testing for people calling my OO methods as normal functions something I want to do ?"<p>If it is important to you, you help newbies who do "Module::new" by mistake.<p>If not, ignore the report of the untested path from D::C and move on.<p>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 [id://378586|Lessons learned from getting to 100% with Devel::Cover] about my struggles and discoveries from doing a deep testing effort.
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-189168">
<p><i>...reality must take precedence over public relations, for nature cannot be fooled. - R P Feynmann
</i></p>
</div></div>
496486
496819