[xdebug-general] Re: coverage not reported on code being executed

From: Marcus Bointon <marcus[@]bointon.com>
Date: Wed, 5 Sep 2007 08:45:44 +0100

On 5 Sep 2007, at 01:07, Mark Slater wrote:

> Annoying problem: Our product is a web application. That means that
> some variables aren't filled in unless the code is in a web
> request. But when I try to have coverage reported over the whole
> product, it seems that XDebug tries to execute each line because it
> fails on things like:
> [PHP Error] Undefined index: SERVER_PORT [line # of /path/to/
> file.php]
> Is there anyway to get around that? Our unit tests are intended for
> offline execution, but if XDebug is going to insist that all lines
> be executable (even ones our tests won't actually touch) then it
> severely reduces our ability to use it outside a rather limited set
> of files.

I've run into something similar in normal execution because I have
code that is run through both the web server and CLI, so I just have
conditional code in those places and check that vars are defined
before I use them. The only workaround I can think of is to make an
artificial server environment for the script to run in. I know that
simpletest can do this but I don't know if xdebug can provide it too
(maybe define a bunch of environment vars in your test setup script).
Either that or run your tests via a server using something like


Marcus Bointon
marcus@bointon.com | http://www.bointon.com/
Received on Wed Sep 05 2007 - 09:53:19 BST

This archive was generated by hypermail 2.2.0 : Mon Jun 25 2018 - 06:00:04 BST