Giter Site home page Giter Site logo

Comments (4)

dolmen avatar dolmen commented on August 19, 2024

It is a bad idea to try to cheat with what Devel::Cover reports.
If you want 100% code coverage, you should instead fix your testsuite:

use Test::Exception;
throws_ok { mysub(0) } 'this should never happen', 'unexpected case';

from devel--cover.

macrotex avatar macrotex commented on August 19, 2024

While I agree that in most circumstances you want to try and achieve full coverage, there are instances and circumstances where it is either very difficult or impossible to generate full coverage in testing (e.g., external faults that are hard to simulate).

from devel--cover.

dolmen avatar dolmen commented on August 19, 2024

I think that your problem is that you fixed 100% code coverage as an aim to reach. That's broken, as 100% doesn't mean much anyway: that doesn't measure if you tested all combinations of code branches.

from devel--cover.

pjcj avatar pjcj commented on August 19, 2024

I don't disagree with what dolmen says, but I also think that there are times when you know that you cannot exercise some code, for whatever reason, and in such cases it is useful to be able to mark the code such that it doesn't keep showing up as an error, thus making real problems harder to see.

In this particular case, add the following comment on the line before if ($x > 0):

uncoverable branch false count:2

This indicates that the second branch coming up (this is how perl models elsif) should never be false. If it is, it will be marked as an error.

ac4e370 documents this, to a certain extent.

from devel--cover.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.