Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No reports or PHPUnit coverage #147

Closed
gubler opened this issue May 23, 2014 · 22 comments
Closed

No reports or PHPUnit coverage #147

gubler opened this issue May 23, 2014 · 22 comments

Comments

@gubler
Copy link

gubler commented May 23, 2014

When I run phpdox 0.6.6 I have two problems:

1 - No information from the PHPUnit enricher

Next to all of my classes it just says UNTESTED. I have PHPUnit 4.1, and its code coverage xml files are in build/coverage/xml and the relevant portion on my phpdox.xml is

<enrich base="${basedir}/build">
    <source type="phpunit">
        <coverage path="coverage/xml" />
    </source>
</enrich>

I get no errors thrown when I run phpdox.

2 - Broken Reports link

The top navbar link for reports goes to an ungenerated file. I'm not sure what is supposed to be in that file, but neither a reports.html nor a reports/index.html are generated.

@theseer
Copy link
Owner

theseer commented May 23, 2014

1 - No information from the PHPUnit enricher

Can you verify this behavior with the latest code base from git? Particularly commit 22bc153 might have fixed that.

2 - Broken Reports link

That's unfortunately a bad commit from my development state that shouldn't have made it into a release. The report link should have been commented out as I'm still busy writing the report generator part.

@gubler
Copy link
Author

gubler commented May 24, 2014

untested

No luck :(

Here's the output from the phpDox command:

phpDox 0.6.6.1-7-gf5ca9c7-dirty - Copyright (C) 2010 - 2014 by Arne Blankerts

[24.05.2014 - 09:48:46] Using config file '/Users/barbariangeek/Sites/wsbapi/phpdox.xml'
[24.05.2014 - 09:48:46] Registered collector backend 'parser'
[24.05.2014 - 09:48:46] Registered enricher 'build'
[24.05.2014 - 09:48:46] Registered enricher 'git'
[24.05.2014 - 09:48:46] Registered enricher 'checkstyle'
[24.05.2014 - 09:48:46] Registered enricher 'pmd'
[24.05.2014 - 09:48:46] Registered enricher 'phpunit'
[24.05.2014 - 09:48:46] Registered enricher 'phploc'
[24.05.2014 - 09:48:46] Registered output engine 'xml'
[24.05.2014 - 09:48:46] Registered output engine 'html'
[24.05.2014 - 09:48:46] Starting to process project 'WsbApi'
[24.05.2014 - 09:48:46] Starting collector
[24.05.2014 - 09:48:46] Scanning directory '/Users/barbariangeek/Sites/wsbapi/src' for files to process

ccccc                                               [5]

[24.05.2014 - 09:48:46] Saving results to directory '/Users/barbariangeek/Sites/wsbapi/build/phpdox/xml'
[24.05.2014 - 09:48:46] Collector process completed

[24.05.2014 - 09:48:46] Starting generator
[24.05.2014 - 09:48:46] Loading enrichers
[24.05.2014 - 09:48:46] Enricher Build Information initialized successfully
[24.05.2014 - 09:48:46] Enricher PHPLoc xml initialized successfully
[24.05.2014 - 09:48:46] Enricher GIT information initialized successfully
[24.05.2014 - 09:48:46] Enricher CheckStyle XML initialized successfully
[24.05.2014 - 09:48:46] Enricher PHPUnit Coverage XML initialized successfully
[24.05.2014 - 09:48:46] Enricher PHPMessDetector XML initialized successfully
[24.05.2014 - 09:48:46] Starting event loop.

..................................................  [50]
..................                                  [68]

[24.05.2014 - 09:48:46] Generator process completed
[24.05.2014 - 09:48:46] Processing project 'WsbApi' completed.


Time: 175 ms, Memory: 1.50Mb

@theseer
Copy link
Owner

theseer commented Sep 11, 2014

Sorry for the long delay.
I'd like to ask you to verify if the problem still remains with phpDox 0.7.0.

If your problem still exists, I'd like you to enable the xml output engine and drop me one of the generated xml files (Important: Not the workdir version but the xml output engine file as that is the one that is enriched!). Make sure you pick a unit you consider covered by tests. In case you have privacy concerns, feel free to send me the file by email and/or remove the majority of methods as mainly the enrichment section is important.

@aGustafsson
Copy link

I had the same problem and the following fix worked for me ...
In the file "src/generator/enricher/phpunit/PHPUnit.php" I changed (line 84-ish) ...

$query = sprintf('//pu:project/pu:directory[@name = "%s"]', $srcDir->getRealPath());
foreach($paths as $path) {
    $query .= sprintf('/pu:directory[@name = "%s"]', $path);
}

... to ...

$query = '//pu:project';
foreach($paths as $path) {
    $query .= sprintf('/pu:directory[@name = "%s"]', $srcDir->getRealPath() . '/' . $path);
}

... definately not the "right" solution but it works for me at the moment and might at least point you in the right direction.

@theseer
Copy link
Owner

theseer commented Sep 19, 2014

That "fix" confuses me as it would imply that the phpunit code coverage xml would have the full path in every directory node whereas it is only supposed to be the name of the directory itself. So your solution would only work if you do not have any sub-directories resulting basically in having the for-each loop only do one iteration.

A reason why this might happen and your solutions works in said case though is that the base directories differ: Assuming phpDox would exclude say "src" from /some/path/src as base and phpunit's coverage report includes it, the entry point used within phpDox would of course be wrong.

Can you verify if that is the case?

@aGustafsson
Copy link

This is what happens in my setup ...

phpUnit generates ...

<phpunit ...>
  <project name="/var/product">
    <tests>...</tests>
    <directory name="/var/product">
      <totals>...</totals>
      <directory name="source">
        <totals>...</totals>
        <directory name="Product">

... but phpDox looks for ...

//pu:project/pu:directory[@name="/var/product/source"]/pu:directory[@name="Product"]

... which it can't find.

(and yes, my "fix" only worked with flat dir. structure.)

If I instead change src/generator/enricher/phpunit/PHPUnit.php line 84 to ...

$query = sprintf('//pu:project/pu:directory[@name = "%s"]', '/var/product');

... phpDox works fine with subdirs.)

@parsingphase
Copy link

Also getting this with https://github.com/parsingphase/enigma-simulator/tree/phpdox-no-coverage - run ant install-dev clean build.

Then compare docs/coverage/index.html (note the 'zero coverage' for classes / traits though... is that the source?)

phpunit-coverage

with docs/html/classes.xhtml.

phpdox-overview

Afraid this isn't exactly a minimal example, but it should at least demonstrate the issue. Or may just work for you, who knows?

@parsingphase
Copy link

No, it's nothing to do with PhpUnit's strict requirement for 100% testing, I've just shunted one of my classes to 100% testing and it still shows as 'untested' in the PhpDox output.

@theseer
Copy link
Owner

theseer commented Oct 1, 2014

The definition if something is considered "tested" by phpDox is based on the following logic:

  • Not executable (e.g. an in interface): EMPTY
  • No tests or contains incomplete / skipped tests: UNTESTED (this may be a bit too strict though)
  • Failures or Errors: FAILED
  • All tests passed: PASSED

As no test info is found, the units are marked UNTESTED.

The problem though is laying within the path definitions. phpDox currently makes the (obviously sometimes invalid) assumption its source directory and the one used by PHPUnit are identical.

Thank you for providing the test repository, as it showcases the problem quite nicely: phpDox is configured to use ${basedir}/src as its source while PHPUnit's coverage report starts at ${basedir}/src/Phase/Enigma.

That also explains why the previously mentioned workarounds fixes the problem.

I'll investigate with @sebastianbergmann on why that actually is and how to fix it best / synchronize the behaviors. In worst case I'll add another config option to phpDox's enriching renderer.

@parsingphase
Copy link

Thanks @theseer, that's much appreciated. For the moment I'll see if I can adjust my paths to keep my own project happy, but I'll leave the phpdox-no-coverage tag in there so that the Enigma repo continues to be useful as a test environment.

@parsingphase
Copy link

I can confirm that revising the path in phpdox.xml works:

wechsler@tahr:~/host/repos/enigma-simulator$ git diff    
diff --git a/phpdox.xml b/phpdox.xml
index 5a21624..54fda48 100644
--- a/phpdox.xml
+++ b/phpdox.xml 
@@ -9,7 +9,7 @@
     <bootstrap />

     <!-- A phpDox project to process, you can have multiple projects in one config file -->
-    <project name="phpdox" source="${basedir}/src" workdir="${basedir}/build/phpdox/xml">
+    <project name="phpdox" source="${basedir}/src/Phase/Enigma" workdir="${basedir}/build/phpdox/xml">

parsingphase added a commit to parsingphase/enigma-simulator that referenced this issue Oct 1, 2014
@jkobus
Copy link

jkobus commented Oct 4, 2014

👍 same issue

@dstockto
Copy link
Contributor

dstockto commented Oct 8, 2014

Same here. I cannot seem to make a path that both doesn't have an error and seems to do anything to the output. Everything is still "untested" even though the entire codebase has 100% coverage.

As a side note, is it possible to enrich with coverage from the output of multiple phpunit runs?

theseer added a commit that referenced this issue Oct 13, 2014
Changed path resolution (Fixes issue #147)
@theseer
Copy link
Owner

theseer commented Oct 13, 2014

The fix supplied should make the previously mentioned workaround superfluous.
If the current codebase works for everyone, I'll close this ticket and make a new release.

@theseer
Copy link
Owner

theseer commented Oct 13, 2014

@dstockto phpDox does not support multiple coverage sources. You can merge multiple coverage files with phpcov.

@parsingphase
Copy link

dev-master 96317ac gives me code coverage in the phpdox output, but no reports tab (is that still supposed to be generated?), with source="${basedir}/src" at https://github.com/parsingphase/enigma-simulator/tree/phpdox-147-coverage-works

@theseer
Copy link
Owner

theseer commented Oct 13, 2014

@parsingphase Thank you for testing it. The reports tab shouldn't have made it into the release as it was only there for a PoC implementation of the reports subsystem. I removed the code for that though as I was unhappy with the design and will re-implement it.

@parsingphase
Copy link

Excellent, thanks.

@dstockto
Copy link
Contributor

@theseer I am using phpcov to merge coverage reports for other reports like clover, html and crap4j output. I haven't seen that there's any option that will merge the coverage reports into junit xml. Is there another tool or technique I should be using?

@theseer
Copy link
Owner

theseer commented Oct 13, 2014

@sebastianbergmann any pointers? ;-)

@theseer
Copy link
Owner

theseer commented Oct 13, 2014

I consider this issue fixed.
Please open new issues/feature requests if needed.

@theseer theseer closed this as completed Oct 13, 2014
@theseer
Copy link
Owner

theseer commented Oct 14, 2014

For tracking purposes: the issue for the phpcov feature request is sebastianbergmann/phpcov#27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants