dancryer / PHPCI

PHPCI is a free and open source continuous integration tool specifically designed for PHP.
BSD 2-Clause "Simplified" License
2.42k stars 439 forks source link

Do not see PHP Unit output / Showing Screenshot URLs of Selenium Tests #980

Open amenk opened 9 years ago

amenk commented 9 years ago

I have a PHP Unit test with selenium tests. I would like to see the screenshot URLs.

When I execute PHPunit manually I get

PHPUnit 4.8-dev by Sebastian Bergmann and contributors.

.E

Time: 22.55 seconds, Memory: 4.75Mb

There was 1 error:

1) Example::testKaputt
Current URL: http://www.example.com/
Screenshot: http://phpci.me.local/screenshots/3e2d23019cee95070e6cd97a52f0b552.png

Failed asserting that false is true.

Caused by
Failed asserting that false is true.

/home/me/local-workspace/phpci/PHPCI/build/57/tests/xxxTest.php:32

FAILURES!
Tests: 2, Assertions: 2, Errors: 1.

But in the build protocol I just see

PLUGIN: SUCCESS
RUNNING PLUGIN: php_unit
PLUGIN: FAILED
BUILD FAILED
Removing Build.

my phpci.yml:

setup:
    composer:
        action: "install"
        prefer_dist: true

test:
    php_unit:
        config: phpunit.xml

phpunit.xml:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false"
         syntaxCheck="false">
    <testsuites>
        <testsuite name="Application Test Suite">
            <directory>./tests/</directory>
        </testsuite>
    </testsuites>
    <php>
        <env name="APP_ENV" value="testing"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="SESSION_DRIVER" value="array"/>
    </php>
</phpunit>
mavimo commented 9 years ago

@amenk The behavior is correct, since the PHP unit test if failing the plugin return "failed" status and the build is completed. There is a copy plugin that you can use to copy screenshot files before complete (and delete build folder).

amenk commented 9 years ago

The screenshots storage is not the problem. They are stored outside the build folder. My problem is, that I do not see the output of PHPunit with the link to the screenshot. Is there some kind of verbose mode for preserving the PHPunit output somewhere?

mavimo commented 9 years ago

@amenk can you configure a report file in phpunit.xml file as described on config. I'm not sure you can log this informations here, but you can test and let us know :)

eg:

<logging>
  <log type="xml" target="/tmp/logfile.xml"/>
</logging>
amenk commented 9 years ago

I used

<logging>
  <log type="json" target="/tmp/logfile.json"/>
</logging>

as there is no type="xml" option (correct link is https://phpunit.de/manual/current/en/appendixes.configuration.html)

So the output, including the screenshot location is written to that file.

But how can I have the contents of this file displayed in PHPCI ?

mavimo commented 9 years ago

@amenk I'm sorry but currently is not possibile display external file in logs without alter the default phpci behavior.

amenk commented 9 years ago

so can that be added as a feature? Could also be displayed in a seperate "details section"

mavimo commented 9 years ago

You can consider to introduce a new project config to "embed" a file in the build result page using interpolation token so you can see generated markup (should be useful also for display some other plugin output) but I'm not sure is a good way to procede.

Another solution is to create a new mail template and customize template to add embed the result file with file url o create and external app to list all generated files and display the generated screenshot.

Adirelle commented 9 years ago

IMO a plugin to store files created during the build would be a good idea. However, this also would require some kind of cleanup when the build are removed.

ptejada commented 8 years ago

Hi,

Are there updates on this? the tap output is not the most useful as it does not really tells you what went wrong with an error or failure. Ideally the phpunit plugin uses the --log-tap instead of --tap, this way is possible to display the useful output in the "Build Log" tab.