If you read this post, you'll notice that my Test::Class driver script allows the following syntax:
t/test_class_tests.t path/to/test/class/to/run.pm
However, some of my tests are in Test::Class style and some of my tests are old-style test scripts. I bound two keys in vim to handle them (,T and ,t, respectively), but that was annoying, so I just wrote this:
if exists( "perl_tests" ) finish endif let perl_tests = 1 noremap,t :call RunTests() function RunTests() if match(getline(1), 'package') > -1 execute ":!perl t/test_class_tests.t %" else execute ":!prove -lv %" endif endfunction
If you're using my Test::Class driver script or a similar variation and you save the above in something like ~/.vim/plugin/PerlTests.vim, then whenever you hit ,t, you will run the tests in whatever test file you're working on. It assumes that all Test::Class files have a package declaration on the first line, though, so not everyone will be happy with that. Improvements welcome!
Checking to see if a file is named test.pl, ends in .t or is a regular package which actually uses Test::Class would be good improvements.