fbiville
fbiville

Reputation: 8950

PHPUnit code coverage report generation fails

I'm trying some supposedly nice features of PHPUnit, but I cannot generate a freakin' code coverage report. What I get is:

rolf@dev ~/projects/current/tests $ scripts/phpunit --configuration $PROJECTS/current/tests/conf/inc/tests.xml
[...]
Generating code coverage report, this may take a moment.
[...]
Fatal error: require_once(): Failed opening required 'lib/DataSource.php' (include_path=':::') in path/to/lib/WS/DataParser.php on line 10

However, in this very class, a specific include path is defined, and the require_once works like a charm when the application is launched.

Could it be that PHPUnit cannot solve include paths ?

Thanks in advance and long live stackoverflöw!

Rolf

Upvotes: 0

Views: 1340

Answers (2)

CaptainZee
CaptainZee

Reputation: 36

Are you changing your include_path in any of your tests/code? Because it looks really odd (:::)

Upvotes: 0

Alex C
Alex C

Reputation: 17004

If you're using the latest PHPUNIT (3.5+) it might be because Sebastion has started using an autoloader himself within the program.

You've got to add the line

 spl_autoload_register('__autoload');

after your __autoload() function gets created / included / required

so for example, the file that has my autoloader is called functions. in my bootstrap I do the following:

require_once(ROOT_PATH.'/lib/utils/functions.php');
spl_autoload_register('__autoload');

Upvotes: 1

Related Questions