PHPUnit-Immediate-Exception-Printer icon indicating copy to clipboard operation
PHPUnit-Immediate-Exception-Printer copied to clipboard

Option to only show a dot for green tests

Open Firesphere opened this issue 7 years ago • 9 comments

The output is pretty long and easily overlooked. An option to only output failed tests or tests that take a long time would be a good asset.

Firesphere avatar May 21 '17 05:05 Firesphere

Unfortunately there is currently no way to specify printer options in PHPUnit. I think the linked issue would need to be resolved before considering this.

See sebastianbergmann/phpunit#2557.

Bilge avatar May 21 '17 08:05 Bilge

Could you have a couple of pre-configured printers made available as separate classes in the module? E.g. provide ScriptFUSION\PHPUnitImmediateExceptionPrinter\TerseImmediateExceptionPrinter as well, which is a subclass of ImmediateExceptionPrinter that changes some parameters.

I agree that it would be nicer if it was fixed up-stream, but pending that, would it make sense to work with what we have?

sminnee avatar May 22 '17 21:05 sminnee

We could definitely ship lots of specializations but that's a maintenance nightmare. One guy wants to replace success lines with just a dot. Another guy wants no output at all for successful tests. Very soon we have a class explosion and then a long list of BC breaks when we delete them all because the upstream issue is fixed. I think it should be a priority to create a PR to pass options to printers in PHPUnit so we can configure them to our heart's content and make everyone happy in a maintainable way.

As an aside, the idea to have no output at all for success cases and then to integrate that with Travis is a perilous one that I can strongly advise against because Travis has a stalled build detection feature that activates when there isn't any output within a given time limit. In the typical case where your build has no errors you will see absolutely no output which is not only a poor user experience but has the potential to crash your build due to timeouts. Ergo the dot idea was better.

Bilge avatar May 22 '17 22:05 Bilge

Sorry to put my comment at https://github.com/silverstripe/silverstripe-framework/pull/6945#issuecomment-303213181 in context, I meant to "print VERBOSE information on errors", not suppress all output. :)

At the moment the only information we need for success is that it passed; The current "." (green dot) is fine for this in our case.

tractorcow avatar May 23 '17 00:05 tractorcow

I left a relevant comment at https://github.com/silverstripe/silverstripe-framework/pull/6941#issuecomment-303255739

tractorcow avatar May 23 '17 00:05 tractorcow

We could definitely ship lots of specializations but that's a maintenance nightmare.

All that we need is the ability to customise the printer; A great outcome to this solution could be, rather than a pre-configured printer, maybe a simple "how to subclass and override the core printer class" with a simple example, perhaps a markdown file linked to from the root index?

tractorcow avatar May 23 '17 00:05 tractorcow

On second thoughts, core documentation may not even be necessary, if you wanted to keep the focus of your module pretty well defined.

If you could post an example of how to (as I would guess would be required) customise onEndTest from https://github.com/ScriptFUSION/PHPUnit-Immediate-Exception-Printer/blob/master/src/Printer.php that would be enough for us, as well as others who look up this ticket. :)

tractorcow avatar May 23 '17 00:05 tractorcow

Unfortunately there is currently [no way to specify printer options

In absence of any infrastructure provided by PHPUnit, this printer could read a config file upon first time initialization and read configuration options from there. Something like phpunit-exception-printer.(json|yaml|xml|younameit).dist etc.

I would love to use it but the point would be to "see the errors" ASAP but with large test suites the immediately get washed away with all the success responses.

mfn avatar Oct 23 '18 05:10 mfn

In my fork (see https://github.com/ScriptFUSION/PHPUnit-Immediate-Exception-Printer/issues/9#issuecomment-567243426 ) I actually implemented this.

Not very elegant, but at least it's configurable. I can share the pain with big test suites (talking >5k tests) which literally pages and pages of successful lines when all you really need are the failures.

mfn avatar Dec 18 '19 22:12 mfn