This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 201623 - Code Coverage does not work
Summary: Code Coverage does not work
Status: RESOLVED WORKSFORME
Alias: None
Product: php
Classification: Unclassified
Component: Project (show other bugs)
Version: 7.0
Hardware: All All
: P3 normal with 1 vote (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-05 10:33 UTC by Tomas Mysik
Modified: 2012-03-27 08:53 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Coverage file generated by netbeans and not working (3.12 KB, application/xml)
2011-09-10 11:39 UTC, patkoscsaba
Details
PHPUnitLog file generated by netbeans and not working (822 bytes, application/xml)
2011-09-10 11:40 UTC, patkoscsaba
Details
Project which does not show any coverage data (77.77 KB, application/x-gzip)
2011-09-12 17:44 UTC, patkoscsaba
Details
PhpUnit XML log (564 bytes, text/xml)
2011-09-13 09:29 UTC, Tomas Mysik
Details
Code coverage XML log (2.95 KB, text/xml)
2011-09-13 09:29 UTC, Tomas Mysik
Details
Example project's coverage file (2.95 KB, text/xml)
2011-09-13 16:48 UTC, patkoscsaba
Details
Example project's phpunit log (562 bytes, text/xml)
2011-09-13 16:49 UTC, patkoscsaba
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Mysik 2011-09-05 10:33:15 UTC
Detailed information can be found in issue #180254, comment #30 and comment #31.
Comment 1 Tomas Mysik 2011-09-05 11:54:20 UTC
BTW you have provided incomplete NB sample project (reference to /var/www), I had to fix the test directory and require_once() in the test file. Then, code coverage works fine for me.

What comes to my mind:
- have you enabled the code coverage? Right click the project and choose Code Coverage > Collect and Disply Code Coverage
- reopen this issue and attach the generated code coverage [1]

[1] start NetBeans with "-J-Dnb.php.phpunit.keeplogs=true" and find the generated <tmp-dir>/nb-phpunit-coverage.xml.

Product Version: NetBeans IDE Dev (Build 20110901-32c9999f02d6)
Java: 1.6.0_24; Java HotSpot(TM) 64-Bit Server VM 19.1-b02
System: Linux version 2.6.38-11-generic running on amd64; UTF-8; cs_CZ (nb)
Comment 2 patkoscsaba 2011-09-10 11:39:20 UTC
Created attachment 110599 [details]
Coverage file generated by netbeans and not working
Comment 3 patkoscsaba 2011-09-10 11:40:00 UTC
Created attachment 110600 [details]
PHPUnitLog file generated by netbeans and not working
Comment 4 patkoscsaba 2011-09-10 11:40:33 UTC
I reopened this bug because I have the same problem. 


Product Version: NetBeans IDE 7.0.1 (Build 201107282000)
Java: 1.6.0_26; Java HotSpot(TM) 64-Bit Server VM 20.1-b02
System: Linux version 3.0.4-desktop-nrj.69mib running on amd64; UTF-8; en_US (nb)
Userdir: /home/csaba/.netbeans/7.0

phpUnit 3.5.15, SO is Linux Mandriva 2011

Attached the files requested.
Comment 5 Tomas Mysik 2011-09-12 12:12:16 UTC
To patkoscsaba@netbeans.org:

Thanks for the attached files, I will have a look at them. BTW would it be possible to have a (sample) project where the code coverage does not work? It would help us a lot.

Thanks.
Comment 6 patkoscsaba 2011-09-12 15:21:15 UTC
I can do a sample project, too, if necessary. But does it have any relevance if on my machine with all and any php project the problem is the same? Anyway, I will upload a test project this evening (at about 6PM GMT)
Comment 7 patkoscsaba 2011-09-12 17:44:04 UTC
Created attachment 110674 [details]
Project which does not show any coverage data

Here is a simple project. One class with one method and one test for it. The test obviously passes. In output I can see that coverage data was generated. However in NetBeans the coverage bar shows 0.00% in red
Comment 8 Tomas Mysik 2011-09-13 09:28:53 UTC
I can't reproduce your issue, attaching the PhpUnit and code coverage XML log so we can compare them.

Please, do the same, I will compare those files and try to find the problem.

Thanks.
Comment 9 Tomas Mysik 2011-09-13 09:29:31 UTC
Created attachment 110695 [details]
PhpUnit XML log
Comment 10 Tomas Mysik 2011-09-13 09:29:51 UTC
Created attachment 110696 [details]
Code coverage XML log
Comment 11 Tomas Mysik 2011-09-13 09:30:46 UTC
Please, attach your files and reopen this issue.

Thanks.
Comment 12 patkoscsaba 2011-09-13 16:48:33 UTC
Created attachment 110721 [details]
Example project's coverage file
Comment 13 patkoscsaba 2011-09-13 16:49:10 UTC
Created attachment 110722 [details]
Example project's phpunit log
Comment 14 patkoscsaba 2011-09-13 16:49:35 UTC
Attached files you requested
Comment 15 patkoscsaba 2011-09-13 16:54:50 UTC
I compared the files and I can see no differences (except some timestamps and file paths).

I am thinking, without knowing the inner working of NetBeans, is it possible that some PlugIn prevents code-coverage from working correctly?

If this still can't help you figure out what's wrong I will also try a nightly build to see if it is also happening with it.
Comment 16 Tomas Mysik 2011-09-14 09:01:42 UTC
(In reply to comment #15)
> I compared the files and I can see no differences (except some timestamps and
> file paths).

Confirmed.

> I am thinking, without knowing the inner working of NetBeans, is it possible
> that some PlugIn prevents code-coverage from working correctly?

I don't think so but I'm not 100 % sure.

> If this still can't help you figure out what's wrong I will also try a nightly
> build to see if it is also happening with it.

Yes, please do so. Also, you can try a clean userdir [1]. You can also try a different project. Also, please verify that your IDE log [2] does not contain any relevant exception.

Thanks for your cooperation, closing as WORKSFORME for now, feel free to reopen if you have something new.
[1] http://wiki.netbeans.org/FaqAlternateUserdir
[2] View > IDE Log
Comment 17 patkoscsaba 2011-09-14 14:01:24 UTC
I will do some more testing this evening. About trying a different project, this problem is present for all my projects. Both old projects and projects I create.
Comment 18 patkoscsaba 2011-09-14 18:30:45 UTC
Hmm ... It is finally working after I started NetBeans with a clean profile (by removing ~/.netbeans) Now, I will try to export my settings from the old profile and import them to a new one.
If I can figure out what it causing the problem I will make another comment here. Thanks for the assistance.
Comment 19 Tomas Mysik 2011-09-15 05:21:49 UTC
(In reply to comment #18)
> It is finally working

Great to hear!

> after I started NetBeans with a clean profile (by
> removing ~/.netbeans)

Sorry.

> Now, I will try to export my settings from the old
> profile and import them to a new one.

This should work.

> If I can figure out what it causing the problem I will make another comment
> here.

That would be great.

> Thanks for the assistance.

Thank you for your cooperation.
Comment 20 patkoscsaba 2011-09-15 06:00:41 UTC
Some updates:
1. Exporting "All" from the old profile and importing "All" into a new profile makes the problem to appear again. So, the problem is somewhere in there.
2. I, however, managed to import only the most necessary things for me, and it is working. What can be imported: keyboard shortcuts, files, start page, code templates, formatting and probably the rest from the Editor category. However I had to readd / reopen my projects.
Comment 21 Tomas Mysik 2011-09-15 06:30:11 UTC
(In reply to comment #20)
> Some updates:
> 1. Exporting "All" from the old profile and importing "All" into a new profile
> makes the problem to appear again. So, the problem is somewhere in there.

Would you be able to attach (or email me directly) the file which causes this bug? That would be perfect since I could investigate it and possibly fix the bug.

Thanks.
Comment 22 patkoscsaba 2011-09-15 06:54:01 UTC
I will attach here my exported configuration .zip file, but I can not pinpoint the problem more exactly than I explained in my previous comment. You will have the file at about 8PM GMT.
Comment 23 Tomas Mysik 2011-09-15 07:36:41 UTC
Better send the ZIP file directly to my mail since it could contain some private data (passwords etc.). Please double check it before sending, if possible.

Thanks.
Comment 24 H.Gassner 2012-01-08 11:48:02 UTC
Perhaps this additional info will help:
Beside not getting CodeCoverage info running I also cannot get the debugger running for UnitTests (but debugging works for the project itself without any problems).

When installing Netbeans 7.1 I've imported the setting from my last installation, which was NB 6.9.1.

Thanx for your support
Horst
Comment 25 slevin 2012-01-25 17:15:51 UTC
Some additional information about this bug.

I have made some tests with the same combination of source and test files (create new project, setup test folder, put source and test files inside).

If I create project on disk C: (my system disk), code coverage works.
If I create project on disk D:, code coverage doesn't work.

Product Version: NetBeans IDE 7.1 (Build 201112071828)
Java: 1.7.0_02; Java HotSpot(TM) Client VM 22.0-b10
System: Windows 7 version 6.1 running on x86; Cp1251; en_US (nb)
User directory: C:\Users\V\.netbeans\7.1
Cache directory: C:\Users\V\.netbeans\7.1\var\cache
Comment 26 slevin 2012-01-25 17:21:55 UTC
Sorry, haven't noticed that its Linux bug.
Hope my comment will help to fix it on both Windows and Linux
Comment 27 H.Gassner 2012-02-26 08:09:33 UTC
Same for me - also did not see, that this is a Linix issue. I'm sorry for this.
Nevertheless - to do not confuse you in finding the bug some news from my side.

PhpUnit is now working
-----------------------
I am using WampServer 2.2. Debugging a project in the browser uses the php.ini file inside the Apache directory. But debugging a PhpUnit project uses the php.ini file in the PHP directory. The settings for XDebug were not correct in this file. Sorry for mixing things up!

Code coverage still does not work
---------------------------------
Perhaps this info will help: my project files are on a different drive than the Netbeans files (I mention this since Slevin found out that this might be a reason for code coverage not working).

Code coverage does work before I've updated my WampServer and Netbeans - even if the project files had been in a different directory.
Comment 28 Tomas Mysik 2012-02-27 09:03:11 UTC
(In reply to comment #27)
> PhpUnit is now working

Great to hear.

> Code coverage does work before I've updated my WampServer and Netbeans - even
> if the project files had been in a different directory.

Unlikely to have something with NetBeans if it is used to work; there was no change in this area in NB for a long time. AFAIK PHPUnit uses XDebug for code coverage.

Anyway, once there is a fixing phase, I will ty to evaluate this issue and fix it, if possible.

Thanks.
Comment 29 slevin 2012-02-27 15:18:46 UTC
Hi, Tomas

Could you, please, say when estimated fixing phase come?
Comment 30 Tomas Mysik 2012-02-27 15:27:13 UTC
(In reply to comment #29)
> Could you, please, say when estimated fixing phase come?

http://wiki.netbeans.org/NetBeans_72
Comment 31 Tomas Mysik 2012-03-26 12:31:03 UTC
Apparently reproducible on all platforms.

Let me tell you how the code coverage works in NetBeans - we simply only run PHPUnit script with code coverage on. AFAIK PHPUnit uses XDebug to get this information so if your XDebug is not working properly, the code coverage won't be collected. If it is collected, then NetBeans just parses this file and mark the appropriate lines inthe editor.

(In reply to comment #25)
> If I create project on disk C: (my system disk), code coverage works.
> If I create project on disk D:, code coverage doesn't work.

This is _very_ weird; don't you have any whitespaces in your path, for example? Láďo, could you please try to reproduce? Thanks a lot.

(In reply to comment #27)
> Perhaps this info will help: my project files are on a different drive than
the Netbeans files (I mention this since Slevin found out that this might be
> a reason for code coverage not working).

So it means that the "nbproject" directory is on different drive than your project's PHP files, right? Láďo, again, could you please try to reproduce?

> Code coverage does work before I've updated my WampServer and Netbeans - even
> if the project files had been in a different directory.

If one uses these all-in-one packages (Wamp, Mamp etc.), one also _needs_ to be sure that its setup is OK; I mean all the php.ini files (one can be for Apache, another for CLI), all the PHP Include Paths etc.

So, if anyone can reproduce this issue (with all-in-one package), please do so and let us know your setup, steps to reproduce. Or, if anyone has reliable steps to reproduce (as I have cited above), please provide them, we will try to reproduce and fix.

Also, if anyone can reproduce, follow steps provided in comment #1 and attach the log files.

For now closing as WORKSFORME since I cannot reproduce on Linux, sorry.

Thanks for your cooperation.
Comment 32 cybd 2012-03-26 17:16:51 UTC
Ok, I can reproduce on my Windows machine, just tell me where can I take log files to attach this bug.
Comment 33 slevin 2012-03-26 20:46:46 UTC
(In reply to comment #31)
> (In reply to comment #25)
> > If I create project on disk C: (my system disk), code coverage works.
> > If I create project on disk D:, code coverage doesn't work.
> 
> This is _very_ weird; don't you have any whitespaces in your path, for example?
> Láďo, could you please try to reproduce? Thanks a lot.

That's actually the bug in PHP_CodeCoverage package.

https://github.com/sebastianbergmann/php-code-coverage/issues/93
Comment 34 Tomas Mysik 2012-03-27 08:48:50 UTC
(In reply to comment #32)
> Ok, I can reproduce on my Windows machine, just tell me where can I take log
> files to attach this bug.

I wrote it in my last comment:

> Also, if anyone can reproduce, follow steps provided in comment #1 and
> attach the log files.
Comment 35 Tomas Mysik 2012-03-27 08:53:28 UTC
Closing back as WORKSFORME and please, do not reopen this issue again since there are more independent reports here. Simply submit a new bug and follow instructions provided in the comment #1.

Thanks for your cooperation.