As I keep dropping to a shell to run my tests I couldn’t help wonder if there was a way I could run them from my eclipse session. Of course you can, and its easy (I’m assuming Linux here):
So what I want to do is replicate this command in eclipse
prove -Ilib t/01_test.t
First setup an external tool: Run –>External Tools–>External Tools Configurations. You should see the following screen:

Right click the Program entry and choose New (if you dont see the Ant and program entries check the filters). You should now see the External Tool Configurations screen.

Location: Set this to the location of prove e.g.
/usr/bin/prove.
Working Directory: To set this to your project directory use the eclipse variable
${project_loc}
This will give you the absolute path to your project directory.
Arguments: This is where we can pass our arguments to prove. As I want to be able to run individual test files I use the eclipse variable ${resource_loc}. This gives me arguments of:
-Ilib ${resource_loc}
Now click Apply and Close. Select your .t file in the navigator view and click the external tools button
If all has gone well you should now see your test running in a console window at the bottom of your workspace.
If you need environment variables, such as DBIC_TRACE or CATALYST_CONFIG_LOCAL_SUFFIX then you can just add them to the Environment tab in the External Tool Configuration screen.
Happy testing!
p.s. You do write tests don’t you?
Adding -I${workspace_loc:Project-Name}/lib can be a handy thing to add to the perl arguments too.
I generally develop packages with CPAN style directory structures (so that they can be made with Module::Build) as separate projects in my workspace. I don’t actually want to have to build, test and install them all every time I want to run the tests however so I add the projects as libraries in my run configurations.
My ‘Test Absolutely Everything’ run configuration has a rather long list of arguments.
Do you use the Eclipse perl debugger too?
@David I do use the debugger, but I tend to use tests to pinpoint errors now.
I just set the Perl build path to find the libs and do ctrl-F11. I’m usually testing one-off scripts these days so I don’t have sophisticated needs at present.
The ability to view the source and test code in side-by-side windows and quickly hit Ctrl-F11 to run the test is probably my favorite thing about using Eclipse for Perl development.
I love my shell, its l33t
This is helpful post. thanks