This is one of the more exciting things I've seen in the testing world
lately:

  http://use.perl.org/~Ovid/journal/36030

And for those who can't follow the link:

Johan Lindstrom's Devel::CoverX::Covered
(http://search.cpan.org/dist/Devel-CoverX-Covered/) is still relatively
new, but are some changes to my .vimrc based on this (stripped down for
clarity):

    function! PerlMappings()
        noremap <buffer> ,cv :call Coverage()<cr>
        noremap K :!perldoc <cword> <bar><bar> perldoc -f <cword><cr>
    endfunction

    function! PerlTestMappings()
        noremap <buffer> ,t :!prove -vl --norc %<CR>
    endfunction

    function! Coverage()
        let filename = bufname('%')
        if match(filename, '\.t$') > -1
            execute '!covered by --test_file="'. filename .'"'
        else
            execute '!covered covering --source_file="'. filename .'"'
        end
    endfunction

    au! FileType perl          :call PerlMappings()
    au! BufRead,BufNewFile *.t :call PerlTestMappings()

When I am editing lib/Bermuda.pm and I type ,cv, I get this:

    t/basic.t
    t/bermuda.t
    t/exceptions.t
    t/serialize.t
    t/subelements.t
    t/xml.t

And if I'm editing t/basic.t and I type ,cv, I get this:

    lib/Bermuda.pm
    lib/Bermuda/Island.pm
    lib/Bermuda/Island/Attribute.pm
    lib/Bermuda/Island/Element.pm
    lib/Bermuda/Island/Metadata.pm
    lib/Bermuda/Parser.pm
    lib/Bermuda/RNG.pm
    lib/Bermuda/Writer.pm

In other words, know what tests will cover your code and vice versa.
Johan has more features on the way, including being able to know which
tests cover a particular line of a file.

Already I need to update my Oslo talk :)

Cheers,
Ovid

--
Buy the book  - http://www.oreilly.com/catalog/perlhks/
Perl and CGI  - http://users.easystreet.com/ovid/cgi_course/
Personal blog - http://publius-ovidius.livejournal.com/
Tech blog     - http://use.perl.org/~Ovid/journal/

Reply via email to