Phpunit: Bring back TAP

Created on 17 May 2017  路  9Comments  路  Source: sebastianbergmann/phpunit

I couldn't find the reason for the removal of TAP logging, and I hadn't seen the deprecation notice for 5.7, or I would have spoken up earlier.

I'd like to argue in favor of bringing back TAP output, simply because it's the only machine-readable output that allows for streaming of progress!

All 9 comments

I work on Heroku CI, and I'd love to see TAP support re-introduced. Due to the fact that TAP is the only somewhat standardized test output format that can be streamed we support it for real time details about what's going on during a test run. Generally all of the JSON and JUnit formats are written after the fact, not while tests are running.

In all the time that PHPUnit had out-of-the-box support for TAP I have never used it and, more importantly, never met somebody who used it. Futhermore, it causes problems due to its dependency on Symfony's YAML component at some point.

Long story short: I will not bring back TAP.

If you need a streaming logger then you should have a look at the TeamCity test listener that is used by PhpStorm, for instance.

If you really need TAP then you can implement your own test listener that emits TAP and configure it in your phpunit.xml. Feel free to use https://github.com/sebastianbergmann/phpunit/blob/5.7/src/Util/Log/TAP.php as the basis for that. There is no need for something like this to be part of the "standard PHPUnit distribution".

Well, that's somewhat unfortunate :\ Has anyone created such a test listener? All google is really telling me is "call phpunit with --log-tap", but that's not available anymore.

If nobody has created such a separate package then, I guess, nobody really misses the functionality enough.

@sebastianbergmann Not sure that it's necessarily a correct assumption. Another option is a matter of prioritization.

This is the top result when googling "phpunit tap" so it should include a proper solution. I'm here because Ubuntu 18.04 LTS was recently released and it upgraded to phpunit 6.

If all you need is to see which tests executed, the easiest solution is to replace --tap with --debug. The output is very similar but --debug is not as good as --tap for scripting.

I also attempted to use my own test listener but there's no obvious way to override the default (ResultPrinter) output. Also, the same listener wouldn't work on phpunit 4, 5, 6 and 7 as the function definitions have changed (to namespaces and then PHP 7 type hints). I don't think there's a way to switch listeners based on phpunit version.

For all those googling and finding this sad issue, here is a solution: https://github.com/gh640/phpunit-tap

@davidolrik PHPUnit is getting a new event system, for which work is already underway by @localheinz and @theseer: a living doc of events to be implemented and the working branch.

The rewrite of the loggers will provide an event stream in a way that is compatible with all filtering, grouping and reordering features. This will make it very simple to implement custom loggers like TAP.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AnmSaiful picture AnmSaiful  路  4Comments

stephen-leavitt-sonyatv-com picture stephen-leavitt-sonyatv-com  路  4Comments

keradus picture keradus  路  4Comments

greg0ire picture greg0ire  路  4Comments

TiMESPLiNTER picture TiMESPLiNTER  路  3Comments