In Test::Class, there is a terribly clunky way to tell it to run only one test (I can call it clunky because I submitted the patch for it). The way to do this is to create a TEST_METHOD environment variable:
package Tests::Customer; use base 'My::Test::Class'; sub foo : Tests(12) { ... } sub bar : Tests { ... } sub baz : Tests(111) { ... } BEGIN { $ENV{TEST_METHOD} = 'quux' } sub quux : Tests(no_plan) { ... }
With the above, you will only have the 'quux' method run. This is very handy when you're focusing on a specific method and don't want to run your other long-running tests until you're done working on 'quux'. With the help of smylers (he really is a vim god, you know), I now have the following vim mapping:
noremap ,tm ?^sub.*:.*Testw"zyeOBEGIN { $ENV{TEST_METHOD} = ' z' }
It's a bit of a hack, but here's what it does. When you type ',tm', it does:
In other words, position your cursor in a method, type ',tm' while in command mode and it will try to create insert code which will only run the test method you're currently in. This really speeds up my testing!
Re:Less hacky
Ovid on 2009-08-22T08:40:00
Excellent. I'll have to add this in.