views:

145

answers:

1

I'm using Eclipse EPIC IDE to write some Perl CGI scripts which call some Perl modules that I have also written. The EPIC IDE lets me configure a Perl CGI "run configuration" which runs my CGI script. And then I've got Selenium set up and one of my unit test files runs some Selenium commands to run my cgi script through its paces. But the coverage report from Module::Build dispatch 'testcover' doesn't show that any of my module code has been executed. It's been executed by my cgi script, but I guess the CGI script was run manually and was not executed directly by my unit test file, so maybe that's why the coverage isn't being recognized. Is there a way to do this right so I can integrate Selenium and unit test files and code coverage all together somehow?

+2  A: 

I'm not familiar with Selenium or EPIC, but one workaround (unless/until someone comes with more native solution) is to simply include "-MDevel::Cover" into the run configuration command line.

Worse comes to worst, add some conditional logic in BEGIN{} block that - based on some selenium environment variable - conditionally does use Devel::Cover

UPDATE:

It should be possible to suppress output from Devel::Cover using -MDevel::Cover=-silent,1

$ perl5.8 -MDevel::Cover -e '{1;}'
Devel::Cover 0.64: Collecting coverage data for branch, blah
Selecting packages matching:
Ignoring packages matching:
blah, blah, blah
---------------------------- ------ ------ ------ ------ ------ ------ ------
File                           stmt   bran   cond    sub    pod   time  total
---------------------------- ------ ------ ------ ------ ------ ------ ------
Total                           n/a    n/a    n/a    n/a    n/a    n/a    n/a
---------------------------- ------ ------ ------ ------ ------ ------ ------


$ perl5.8 -MDevel::Cover=-silent,1 -e '{1;}'

$
DVK
I tried both solutions and neither seemed to work. When I put -MDevel::Cover into the command line of the cgi run configuration, that new module generated some text on stdout that garbled the cgi script header. When I added use Devel::Cover to my unit test file that uses selenium to exercise the cgi script, it gave me similar results like I was getting before from Module::Build dispatch testcover ... no coverage of my module that I know the cgi script is calling routines in.
Kurt W. Leucht
@Kurt - I am not certain whether you can disable Devel::Cover's IO in some usable way, but I can check...
DVK
@Kurt - try `-MDevel::Cover=-slient`, please
DVK
I tried the -MDevel::Cover=-silent option in Eclipse under Arguments in the run configuration and Devel::Cover still output a bunch of text to the stdout which hosed up the http header: Devel::Cover 0.65: Collecting coverage data for branch, condition, statement, subroutine and time. Pod coverage is unavailable. Please install Pod::Coverage from CPAN.Selecting packages matching:Ignoring packages matching: /Devel/Cover[./]
Kurt W. Leucht
@Kurt - Sorry, it's not a switch, it's an argumnet! `-MDevel::Cover=-slient,1`
DVK
Yes. Partial success. Thank you. Now when I run my cgi script using the Eclipse run configuration, Devel::Cover starts collecting data and my script runs real slow as is expected. Problem is that I don't know how to stop the thing other than mash the "terminate" button in Eclipse which terminates the process. So now I have a bunch of binary run files and structure files in the cover_db directory that I don't know what to do with. I'm used to Devel::Cover churning out a nice HTML report when finished with a unit test, but I don't know how to tell it I'm finished in this configuration.
Kurt W. Leucht
@Kurt - See my reply on your follow-up question - I think it should cover your bases (pun intended :)
DVK