Merge pull request #747 from gehrisandro/add-teamcity-testsuite-count

teamcity: add missing test count output
This commit is contained in:
Nuno Maduro
2023-03-29 12:10:45 +01:00
committed by GitHub
5 changed files with 28 additions and 0 deletions

View File

@ -166,6 +166,14 @@ final class Converter
return $this->toRelativePath($path); return $this->toRelativePath($path);
} }
/**
* Gets the test suite size.
*/
public function getTestSuiteSize(TestSuite $testSuite): int
{
return $testSuite->count();
}
/** /**
* Transforms the given path in relative path. * Transforms the given path in relative path.
*/ */

View File

@ -40,6 +40,13 @@ final class ServiceMessage
]); ]);
} }
public static function testSuiteCount(int $count): self
{
return new self('testCount', [
'count' => $count,
]);
}
public static function testSuiteFinished(string $name): self public static function testSuiteFinished(string $name): self
{ {
return new self('testSuiteFinished', [ return new self('testSuiteFinished', [

View File

@ -44,6 +44,8 @@ final class TeamCityLogger
{ {
private ?HRTime $time = null; private ?HRTime $time = null;
private bool $isSummaryTestCountPrinted = false;
/** /**
* @throws EventFacadeIsSealedException * @throws EventFacadeIsSealedException
* @throws UnknownSubscriberTypeException * @throws UnknownSubscriberTypeException
@ -66,6 +68,15 @@ final class TeamCityLogger
); );
$this->output($message); $this->output($message);
if (! $this->isSummaryTestCountPrinted) {
$this->isSummaryTestCountPrinted = true;
$message = ServiceMessage::testSuiteCount(
$this->converter->getTestSuiteSize($event->testSuite())
);
$this->output($message);
}
} }
public function testSuiteFinished(TestSuiteFinished $event): void public function testSuiteFinished(TestSuiteFinished $event): void

View File

@ -1,4 +1,5 @@
##teamcity[testSuiteStarted name='Tests/tests/Failure' locationHint='file://tests/.tests/Failure.php' flowId='1234'] ##teamcity[testSuiteStarted name='Tests/tests/Failure' locationHint='file://tests/.tests/Failure.php' flowId='1234']
##teamcity[testCount count='6' flowId='1234']
##teamcity[testStarted name='it can fail with comparison' locationHint='pest_qn://tests/.tests/Failure.php::it can fail with comparison' flowId='1234'] ##teamcity[testStarted name='it can fail with comparison' locationHint='pest_qn://tests/.tests/Failure.php::it can fail with comparison' flowId='1234']
##teamcity[testFailed name='it can fail with comparison' message='Failed asserting that true matches expected false.' details='at src/Mixins/Expectation.php:343|nat src/Support/ExpectationPipeline.php:75|nat src/Support/ExpectationPipeline.php:79|nat src/Expectation.php:300|nat tests/.tests/Failure.php:6|nat src/Factories/TestCaseMethodFactory.php:100|nat src/Concerns/Testable.php:302|nat src/Support/ExceptionTrace.php:28|nat src/Concerns/Testable.php:302|nat src/Concerns/Testable.php:221|nat src/Kernel.php:86' type='comparisonFailure' actual='true' expected='false' flowId='1234'] ##teamcity[testFailed name='it can fail with comparison' message='Failed asserting that true matches expected false.' details='at src/Mixins/Expectation.php:343|nat src/Support/ExpectationPipeline.php:75|nat src/Support/ExpectationPipeline.php:79|nat src/Expectation.php:300|nat tests/.tests/Failure.php:6|nat src/Factories/TestCaseMethodFactory.php:100|nat src/Concerns/Testable.php:302|nat src/Support/ExceptionTrace.php:28|nat src/Concerns/Testable.php:302|nat src/Concerns/Testable.php:221|nat src/Kernel.php:86' type='comparisonFailure' actual='true' expected='false' flowId='1234']
##teamcity[testFinished name='it can fail with comparison' duration='100000' flowId='1234'] ##teamcity[testFinished name='it can fail with comparison' duration='100000' flowId='1234']

View File

@ -1,4 +1,5 @@
##teamcity[testSuiteStarted name='Tests/tests/SuccessOnly' locationHint='file://tests/.tests/SuccessOnly.php' flowId='1234'] ##teamcity[testSuiteStarted name='Tests/tests/SuccessOnly' locationHint='file://tests/.tests/SuccessOnly.php' flowId='1234']
##teamcity[testCount count='2' flowId='1234']
##teamcity[testStarted name='it can pass with comparison' locationHint='pest_qn://tests/.tests/SuccessOnly.php::it can pass with comparison' flowId='1234'] ##teamcity[testStarted name='it can pass with comparison' locationHint='pest_qn://tests/.tests/SuccessOnly.php::it can pass with comparison' flowId='1234']
##teamcity[testFinished name='it can pass with comparison' duration='100000' flowId='1234'] ##teamcity[testFinished name='it can pass with comparison' duration='100000' flowId='1234']
##teamcity[testStarted name='can also pass' locationHint='pest_qn://tests/.tests/SuccessOnly.php::can also pass' flowId='1234'] ##teamcity[testStarted name='can also pass' locationHint='pest_qn://tests/.tests/SuccessOnly.php::can also pass' flowId='1234']