How do you measure code coverage?
I have a small Dancer1 app and I have started writing tests for the web part. I used to write unit tests, but I have never written tests that test web component. With Dander::Test the task of writing tests is very simple, thank you for that module. But I don't understand one thing. I'm using Devel::Cover to find out what I haven't tests. It works fine with my application model that is created without Dacner, but it does not work for the Dancer routes. Devel::Cover does not create any metrics for such code: any ['get', 'post'] => '/login' => sub { ... } Devel::Cover shows that all my Dacner code is 100% coverd, but this is not true. So this tool does not answer the question what is tested and what is not. So my question is how do you measure coverage of code that is tested?
On Fri, Jan 31, 2014 at 10:15:17AM +0400, ???????? ???????????????????? wrote:
Devel::Cover does not create any metrics for such code:
any ['get', 'post'] => '/login' => sub { ... }
So my question is how do you measure coverage of code that is tested?
This is a known bug/mis-feature in Devel::Cover: https://github.com/pjcj/Devel--Cover/issues/51 In our Dancer app at work I have some spectacularly evil code that works around it. In a module that our coverage checking script loads before anything else, it stuffs a sub-ref into @INC. That sub-ref intercepts any attempt to load the files in which our Dancer routes are defined, and wraps them in: package TheModuleWhoseBrainsWeAreCorrupting; sub main { # our victim's body goes here }main(); Yes, it's effectively a source filter. Yes, it uses regexes to parse perl. Yes, that's why I'm not showing you the code. It's evil, and if you're going to do horrible things like that you should write it yourself so that you understand what's going on. -- David Cantrell | top google result for "topless karaoke murders" On the bright side, if sendmail is tied up routing spam and pointless uknot posts, it's not waving its arse around saying "root me!" -- Peter Corlett, in uknot
OMG. Great hack =) David, thank you very much! I'm not sure that I will implement this solution, because I don't understand all the magic behind the code that should do the trick. Hope it will be solved in Devel::Cover and I will be able just to use `cover` without understanding all the secrets behind it. On Fri, Jan 31, 2014 at 6:00 PM, David Cantrell <david@cantrell.org.uk> wrote:
On Fri, Jan 31, 2014 at 10:15:17AM +0400, ???????? ???????????????????? wrote:
Devel::Cover does not create any metrics for such code:
any ['get', 'post'] => '/login' => sub { ... }
So my question is how do you measure coverage of code that is tested?
This is a known bug/mis-feature in Devel::Cover:
https://github.com/pjcj/Devel--Cover/issues/51
In our Dancer app at work I have some spectacularly evil code that works around it. In a module that our coverage checking script loads before anything else, it stuffs a sub-ref into @INC. That sub-ref intercepts any attempt to load the files in which our Dancer routes are defined, and wraps them in:
package TheModuleWhoseBrainsWeAreCorrupting; sub main { # our victim's body goes here }main();
Yes, it's effectively a source filter. Yes, it uses regexes to parse perl. Yes, that's why I'm not showing you the code. It's evil, and if you're going to do horrible things like that you should write it yourself so that you understand what's going on.
-- David Cantrell | top google result for "topless karaoke murders"
On the bright side, if sendmail is tied up routing spam and pointless uknot posts, it's not waving its arse around saying "root me!" -- Peter Corlett, in uknot _______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
On Tue, Feb 04, 2014 at 09:12:07PM +0400, ???????? ???????????????????? wrote:
I'm not sure that I will implement this solution, because I don't understand all the magic behind the code that should do the trick. Hope it will be solved in Devel::Cover and I will be able just to use `cover` without understanding all the secrets behind it.
It's a very long-standing problem with Devel::Cover, so don't hold your breath! -- David Cantrell | http://www.cantrell.org.uk/david Did you know that shotguns taste like candy canes? Put the barrel in your mouth and pull the trigger for an extra blast of minty goodness!
participants (2)
-
David Cantrell -
Иван Бессарабов