It would be really useful for me if PhpEd included a code coverage tool for use with my unit tests. I use SimpleTest for unit tests, and, fortunately, there is no need for this to be integrated into PhpEd. However, code coverage would need to be implemented into PhpEd, since the only code coverage tools I know of utilize the Xdebug debugger instead of dbg, and I believe that you cannot have both of these installed at the same time. The profiler is the closest thing PhpEd has to a code coverage tool, and could easily be modified to be used as such. The main difference between the kind of report I would want to see with a code coverage tool and the report already displayed by the profiler, is that a code coverage report would need to show which lines were executed 0 times. You would also need to be able to specify which files it should report about. As far as I know there is no setting to make the profiler show which lines were not executed, but if there is, please enlighten me.

Thank you! That provides me with all the data that I need to create custom reports! I wrote a function that only displays the lines that got executed 0 times, but for some reason it sometimes does not display all of the missed lines. Here is the code:

You can optionally pass in an array of modules that you want it to report on exclusively. I would post an example where it does not show all the missed lines but I don't have one that I can post yet. Any ideas why it does not always show all the missed lines?

The same problem occurs with the code that dmitri posted. What is interesting is that the profiler tab that opens up seems to be accurate. It is not reporting the same missed lines as being hit. Are you sure that this is the correct way to get all the hit lines?

Just run the file CodeCoverageTest.php with the profiler and go to the output tab. It shows 0 missed lines in CodeCoverageTest.php.
Go into the Tools->Settings and in the Debugger settings check the box that says Run profiler with debugger. Now put a break point in CodeCoverage.php on the line 37, the one that has $missedLines = null; Now run the debugger on CodeCoverageTest.php and after the break point is reached, examine the variables and you will notice that it shows lines 6 and 8 from CodeCoverageTest.php as being in the $hit_lines array and having a hit count of 1 in the $hit_count array. If you let it finish, and then look at the Profiler tab, it does not show lines 6 or 8 as having been hit. If you delete the commented out code from CodeCoverageTest.php, and run the profiler on it again, it will show line 4 as having been missed(the beginning of the if statement), but still not line 6(the trigger_error line). Please help me!

What do you think? Is there a bug in my code or in the functions that I am calling? Or maybe the problem is specific to my environment? Can someone else try out the example I posted above and tell me if they have this problem too?

Just run the file CodeCoverageTest.php with the profiler and go to the output tab. It shows 0 missed lines in CodeCoverageTest.php

your code isn't correct.
Indeed. Take a look at the $profdata.
In its 'mod_no' array, you'll see that only idices 0, 1 and 2 relate to mod_no=1 (the file you inspect) while all the other relate to mod_no=2 which is CodeCoverage.php.
Therefore you can take only 0, 1 and 2 indices from 'line_no' and 'hit_count' (if needed) subarrays.
If you do this, you'll see that only lines 4, 13 and 14 were hit.

Thank you dmitri! There was no reason for me to believe that dbg_get_profiler_results() would only return the data for one module at at time, since it took no module specifying parameters. I guess since it was in a foreach loop I got stuck in that mindset. Here is the working version of the EchoReport() function in case anyone cares:

I believe that you cannot have both of these installed at the same time. The profiler is the closest thing PhpEd has to a code coverage tool, and could easily be modified to be used as such. The main difference between the kind of report I would want to see with a code coverage tool and the report already displayed by the profiler, is that a code coverage report would need to show which lines were executed 0 times. You would also need to be able to specify which files it should report about. As far as I know there is no setting to make the profiler show which lines were not executed

________________
We are the pioneers in providing toefl and exams with exam pass Download our latest passguide gmat and Florida Memorial University ccna or pass real exam of