Skip to content

Commit

Permalink
Improve regression tests for #3364 exposing both failure modes
Browse files Browse the repository at this point in the history
The new 'instanceof TestCase' check does indeed hide errors in
setUpBeforeClass, but there is also a problem with counting the number
of tests returned when counting the result.
  • Loading branch information
epdenouden authored and sebastianbergmann committed Nov 30, 2018
1 parent 6861732 commit d06451a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
36 changes: 33 additions & 3 deletions tests/end-to-end/regression/GitHub/3364/issue-3364-test.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,47 @@ https://github.com/sebastianbergmann/phpunit/issues/3364
<?php
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = '--teamcity';
$_SERVER['argv'][3] = __DIR__ . '/Issue3364SetupBeforeClassTest.php';
$_SERVER['argv'][4] = __DIR__ . '/Issue3364SetupTest.php';
$_SERVER['argv'][3] = __DIR__ . '/tests';

require __DIR__ . '/../../../../bootstrap.php';
PHPUnit\TextUI\Command::main();
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.


##teamcity[testCount count='4' flowId='%d']

##teamcity[testSuiteStarted name='tests/end-to-end/regression/GitHub/3364/tests' flowId='%d']

##teamcity[testSuiteStarted name='Issue3364SetupBeforeClassTest' locationHint='php_qn://%s%etests%eend-to-end%eregression%eGitHub%e3364%etests%eIssue3364SetupBeforeClassTest.php::\Issue3364SetupBeforeClassTest' flowId='%d']

##teamcity[testFailed name='Issue3364SetupBeforeClassTest' message='throw exception in setUpBeforeClass' details=' %s%etests%eend-to-end%eregression%eGitHub%e3364%etests%eIssue3364SetupBeforeClassTest.php:18|n ' duration='0' flowId='%d']

##teamcity[testFailed name='Issue3364SetupBeforeClassTest' message='throw exception in setUpBeforeClass' details=' %s%etests%eend-to-end%eregression%eGitHub%e3364%etests%eIssue3364SetupBeforeClassTest.php:18|n ' duration='0' flowId='%d']

##teamcity[testSuiteFinished name='Issue3364SetupBeforeClassTest' flowId='%d']

##teamcity[testSuiteStarted name='Issue3364Test' locationHint='php_qn://%s%etests%eend-to-end%eregression%eGitHub%e3364%etests%eIssue3364SetupTest.php::\Issue3364Test' flowId='%d']

##teamcity[testStarted name='testOneWithSetupException' locationHint='php_qn://%s%etests%eend-to-end%eregression%eGitHub%e3364%etests%eIssue3364SetupTest.php::\Issue3364Test::testOneWithSetupException' flowId='%d']

##teamcity[testFailed name='testOneWithSetupException' message='RuntimeException : throw exception in setUp' details=' %s%etests%eend-to-end%eregression%eGitHub%e3364%etests%eIssue3364SetupTest.php:18|n ' duration='10' flowId='%d']

##teamcity[testFinished name='testOneWithSetupException' duration='10' flowId='%d']

##teamcity[testStarted name='testTwoWithSetupException' locationHint='php_qn://%s%etests%eend-to-end%eregression%eGitHub%e3364%etests%eIssue3364SetupTest.php::\Issue3364Test::testTwoWithSetupException' flowId='%d']

##teamcity[testFailed name='testTwoWithSetupException' message='RuntimeException : throw exception in setUp' details=' %s%etests%eend-to-end%eregression%eGitHub%e3364%etests%eIssue3364SetupTest.php:18|n ' duration='0' flowId='%d']

##teamcity[testFinished name='testTwoWithSetupException' duration='0' flowId='%d']

##teamcity[testSuiteFinished name='Issue3364Test' flowId='%d']

##teamcity[testSuiteFinished name='tests/end-to-end/regression/GitHub/3364/tests' flowId='%d']


Time: %s, Memory: %s


ERRORS!
Tests: 4, Assertions: 0, Errors: 2.
Tests: 4, Assertions: 0, Errors: 4.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public static function setUpBeforeClass(): void
throw new \RuntimeException('throw exception in setUpBeforeClass');
}

public function testOne(): void
public function testOneWithClassSetupException(): void
{
$this->fail();
}

public function testTwo(): void
public function testTwoWithClassSetupException(): void
{
$this->fail();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@

use PHPUnit\Framework\TestCase;

class Issue3364Test extends TestCase
class Issue3364SetupTest extends TestCase
{
public function setUp(): void
{
throw new \RuntimeException('throw exception in setUp');
}

public function testOne(): void
public function testOneWithSetupException(): void
{
$this->fail();
}

public function testTwo(): void
public function testTwoWithSetupException(): void
{
$this->fail();
}
Expand Down

0 comments on commit d06451a

Please sign in to comment.