Browse files

Added a notice when no tests where executed so that PHPUnit doesn't r…

…eport "OK (0 Tests)" when using --filter.
  • Loading branch information...
1 parent 0470567 commit b960cd508416f04c74cde6480b31b34ae1888a7b @edorian edorian committed Sep 12, 2012
Showing with 39 additions and 1 deletion.
  1. +1 −0 ChangeLog.markdown
  2. +15 −1 PHPUnit/TextUI/ResultPrinter.php
  3. +23 −0 Tests/TextUI/filter-no-results.phpt
View
1 ChangeLog.markdown
@@ -30,6 +30,7 @@ PHPUnit 3.7.0
* Fixed #523: `assertAttributeEquals()` now works with classes extending internal classes like `ArrayIterator`.
* Fixed #581: Generating a diffs could add extra newlines in Windows.
* Fixed #636, #631: Using selenium in combination with autoloaders that die()d or produced errors when a class could't be found caused led to broken tests.
+* If no tests where executed, for example because of a `--filter`, PHPUnit now prints a "No tests executed" warning instead of "OK (0 tests...)".
* It is possible again to expect the generic `Exception` class.
* Removed `addUncoveredFilesFromWhitelist` configuration setting.
* Removed deprecated `--skeleton-class` and `--skeleton-test` switches. The functionality is now provided by the `phpunit-skel` command of the `PHPUnit_SkeletonGenerator` package.
View
16 PHPUnit/TextUI/ResultPrinter.php
@@ -343,7 +343,21 @@ protected function printHeader()
*/
protected function printFooter(PHPUnit_Framework_TestResult $result)
{
- if ($result->wasSuccessful() &&
+ if (count($result) === 0) {
+ if ($this->colors) {
+ $this->write("\x1b[30;43m\x1b[2K");
+ }
+
+ $this->write(
+ "No tests executed!\n"
+ );
+
+ if ($this->colors) {
+ $this->write("\x1b[0m\x1b[2K");
+ }
+ }
+
+ else if ($result->wasSuccessful() &&
$result->allCompletlyImplemented() &&
$result->noneSkipped()) {
if ($this->colors) {
View
23 Tests/TextUI/filter-no-results.phpt
@@ -0,0 +1,23 @@
+--TEST--
+phpunit --filter testBalanceIsInitiallyZero BankAccountTest ../_files/BankAccountTest.php
+--FILE--
+<?php
+define('PHPUNIT_TESTSUITE', TRUE);
+
+$_SERVER['argv'][1] = '--no-configuration';
+$_SERVER['argv'][2] = '--filter';
+$_SERVER['argv'][3] = 'doesNotExist';
+$_SERVER['argv'][4] = 'BankAccountTest';
+$_SERVER['argv'][5] = dirname(__FILE__).'/../_files/BankAccountTest.php';
+
+require_once dirname(dirname(dirname(__FILE__))) . '/PHPUnit/Autoload.php';
+PHPUnit_TextUI_Command::main();
+?>
+--EXPECTF--
+PHPUnit %s by Sebastian Bergmann.
+
+
+
+Time: %i %s, Memory: %sMb
+
+No tests executed!

0 comments on commit b960cd5

Please sign in to comment.