wiki.techinc.nl/tests/phpunit/MediaWikiPHPUnitResultPrinter.php
Timo Tijhof a05b12a1ce phpunit: Restore default progress reporter and add MWTestDox option
Using TestDox is imho not ideal to use by default:

* Far too noisy as a default, making it difficult to iterate by
  not having previous output nearby.

* The custom "Logs generated" we add for debugging don't actually
  show up, not in the original failure that is buried between success
  mesages, and not in the summary.

  This is imho a requirement both for CI and local dev.

* Test failures are immediately buried and flown past with a lot
  of other information.

Proposal:

* Restore default printer as this commit does, with the previous
  override for adding custom logs.

* Once MWTestDox works correctly per the above, enable it by
  default for CI only, by adding `--printer MWTestDox` to
  phpunit:entrypoint in composer.json, which is basically only
  for use by CI.

  The vendor/bin/php, composer phpunit, and phpunit.php calls,
  and IDE integrations would would remain unaffected.

  One can easily pass `--printer MWTestDox` to bin/phpunit if
  preferred locally, or invoke `composer phpunit:entrypoint -- ...`
  instead at that point.

Bug: T297287
Change-Id: I03391e2da1192156e220819d97ca7d8370199801
2022-06-12 19:22:57 +00:00

20 lines
506 B
PHP

<?php
use PHPUnit\Framework\TestFailure;
use PHPUnit\TextUI\ResultPrinter;
class MediaWikiPHPUnitResultPrinter extends ResultPrinter {
/**
* @param TestFailure $defect
* @return void
*/
protected function printDefectTrace( TestFailure $defect ): void {
parent::printDefectTrace( $defect );
$test = $defect->getTestName();
$log = MediaWikiLoggerPHPUnitExtension::$testsCollection[$test] ?? null;
if ( $log ) {
$this->write( "=== Logs generated by test case\n{$log}\n===\n" );
}
}
}