Comments (4)
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.
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.
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.
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)
- cpancover.com: link to distribution on MetaCPAN HOT 1
- Coverage is merged to one file if there are two files with exactly the same content HOT 1
- Marking a covered line uncoverable can make it count as uncovered HOT 6
- Anonymous block shows first line not covered HOT 2
- Can't use Devel::Cover for pkg_add on OpenBSD HOT 4
- Feature Request: Comments to specify code intended to be covered by test HOT 1
- Convert Devel-Cover db to lcov data format HOT 2
- cover -add_uncoverable_point: Use of uninitialized value $_ in split HOT 2
- Silent mode doesn't suppress "Deleting old coverage for changed file" message HOT 2
- Perl 5.38 method is ignored HOT 1
- Feature request: Record stack trace for selected files/lines
- Really questionable design decision when target in @INC HOT 7
- How do I get debug output from Cover.xs? HOT 2
- Nothing new on cpancover.com since October HOT 1
- Feature to add completely uncovered files to the coverage report HOT 1
- t/e2e/adbm_cond.t fails (if DBM::Deep is installed?) HOT 2
- Devel::Cover with Module::Build::Tiny triggers Unknown option: extra_compiler_flags extra_linker_flags
- Add https: support to cpancover.com HOT 1
- Questionable decision to include perl CORE headers in coverage report
- t/e2e/acond_xor.t: Test failures triggered by change in B::Deparse in Perl blead
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from devel--cover.