How to get Perl CGI script coverage code when running Selenium?

I use the Eclipse EPIC IDE to write some Perl CGI scripts that call some Perl modules, which I also wrote. The EPIC IDE allows me to configure Perl CGI to "run the configuration", which runs my CGI script. And then I have Selenium, and one of my unit test files runs some Selenium commands to run my cgi script through its steps. But the coverage report from the Test Module :: Build dispatch 'testcover' test does not show that any of my module code was executed. It was executed by my cgi script, but I assume that the CGI script was started manually and was not executed directly by my unit test file, so that is probably why the coverage is not recognized. Is there a way to do this correctly so that I can somehow integrate the Selenium and unit test files and code coverage?

+4
source share
1 answer

I am not familiar with Selenium or EPIC, but one workaround (unless until someone comes up with a more native solution), just include "-MDevel :: Cover" in the launch configuration command line.

Even worse, add some conditional logic to the BEGIN {} block, which - based on some selenium environment variable - conditionally does use Devel::Cover

UPDATE

It should be possible to suppress the 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/an/an/an/an/an/an/a ---------------------------- ------ ------ ------ ------ ------ ------ ------ $ perl5.8 -MDevel::Cover=-silent,1 -e '{1;}' $ 
+3
source

Source: https://habr.com/ru/post/1310801/