mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Add Initial teamcity support
This commit is contained in:
24
tests/.snapshots/Failure.php.inc
Normal file
24
tests/.snapshots/Failure.php.inc
Normal file
@ -0,0 +1,24 @@
|
||||
##teamcity[testSuiteStarted name='Tests\tests\Failure' locationHint='file://tests/.tests/Failure.php' 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:312|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:101|nat src/Concerns/Testable.php:262|nat src/Support/ExceptionTrace.php:28|nat src/Concerns/Testable.php:262|nat src/Concerns/Testable.php:217|nat src/Kernel.php:76' type='comparisonFailure' actual='true' expected='false' flowId='1234']
|
||||
##teamcity[testFinished name='it can fail with comparison' duration='100000' flowId='1234']
|
||||
##teamcity[testStarted name='it can be ignored because of no assertions' locationHint='pest_qn://tests/.tests/Failure.php::it can be ignored because of no assertions' flowId='1234']
|
||||
##teamcity[testIgnored name='it can be ignored because of no assertions' message='This test did not perform any assertions' details='' flowId='1234']
|
||||
##teamcity[testFinished name='it can be ignored because of no assertions' duration='100000' flowId='1234']
|
||||
##teamcity[testStarted name='it can be ignored because it is skipped' locationHint='pest_qn://tests/.tests/Failure.php::it can be ignored because it is skipped' flowId='1234']
|
||||
##teamcity[testIgnored name='it can be ignored because it is skipped' message='This test was ignored.' details='' flowId='1234']
|
||||
##teamcity[testFinished name='it can be ignored because it is skipped' duration='100000' flowId='1234']
|
||||
##teamcity[testStarted name='it can fail' locationHint='pest_qn://tests/.tests/Failure.php::it can fail' flowId='1234']
|
||||
##teamcity[testFailed name='it can fail' message='oh noo' details='at tests/.tests/Failure.php:18|nat src/Factories/TestCaseMethodFactory.php:101|nat src/Concerns/Testable.php:262|nat src/Support/ExceptionTrace.php:28|nat src/Concerns/Testable.php:262|nat src/Concerns/Testable.php:217|nat src/Kernel.php:76' flowId='1234']
|
||||
##teamcity[testFinished name='it can fail' duration='100000' flowId='1234']
|
||||
##teamcity[testStarted name='it is not done yet' locationHint='pest_qn://tests/.tests/Failure.php::it is not done yet' flowId='1234']
|
||||
##teamcity[testIgnored name='it is not done yet' message='This test was ignored.' details='' flowId='1234']
|
||||
##teamcity[testFinished name='it is not done yet' duration='100000' flowId='1234']
|
||||
##teamcity[testStarted name='build this one.' locationHint='pest_qn://tests/.tests/Failure.php::build this one.' flowId='1234']
|
||||
##teamcity[testIgnored name='build this one.' message='This test was ignored.' details='' flowId='1234']
|
||||
##teamcity[testFinished name='build this one.' duration='100000' flowId='1234']
|
||||
##teamcity[testSuiteFinished name='Tests\tests\Failure' flowId='1234']
|
||||
|
||||
[90mTests:[39m [31;1m2 failed[39;22m[90m,[39m[39m [39m[33;1m1 risky[39;22m[90m,[39m[39m [39m[36;1m2 todos[39;22m[90m,[39m[39m [39m[33;1m1 skipped[39;22m[90m (2 assertions)[39m
|
||||
[90mDuration:[39m [39m1.00s[39m
|
||||
|
||||
10
tests/.snapshots/SuccessOnly.php.inc
Normal file
10
tests/.snapshots/SuccessOnly.php.inc
Normal file
@ -0,0 +1,10 @@
|
||||
##teamcity[testSuiteStarted name='Tests\tests\SuccessOnly' locationHint='file://tests/.tests/SuccessOnly.php' 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[testStarted name='can also pass' locationHint='pest_qn://tests/.tests/SuccessOnly.php::can also pass' flowId='1234']
|
||||
##teamcity[testFinished name='can also pass' duration='100000' flowId='1234']
|
||||
##teamcity[testSuiteFinished name='Tests\tests\SuccessOnly' flowId='1234']
|
||||
|
||||
[90mTests:[39m [32;1m2 passed[39;22m[90m (2 assertions)[39m
|
||||
[90mDuration:[39m [39m1.00s[39m
|
||||
|
||||
@ -893,9 +893,10 @@
|
||||
- visual snapshot of test suite on success
|
||||
|
||||
WARN Tests\Visual\TeamCity
|
||||
- it is can successfully call all public methods → Not supported yet.
|
||||
- visual snapshot of team city with ('Failure.php')
|
||||
- visual snapshot of team city with ('SuccessOnly.php')
|
||||
|
||||
PASS Tests\Visual\Version
|
||||
✓ visual snapshot of help command output
|
||||
|
||||
Tests: 4 incomplete, 4 todos, 17 skipped, 624 passed (1511 assertions)
|
||||
Tests: 4 incomplete, 4 todos, 18 skipped, 624 passed (1511 assertions)
|
||||
26
tests/.tests/Failure.php
Normal file
26
tests/.tests/Failure.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
it('can fail with comparison', function () {
|
||||
expect(true)->toEqual(false);
|
||||
});
|
||||
|
||||
it('can be ignored because of no assertions', function () {
|
||||
|
||||
});
|
||||
|
||||
it('can be ignored because it is skipped', function () {
|
||||
expect(true)->toBeTrue();
|
||||
})->skip("this is why");
|
||||
|
||||
it('can fail', function () {
|
||||
$this->fail("oh noo");
|
||||
});
|
||||
|
||||
it('is not done yet', function () {
|
||||
|
||||
})->todo();
|
||||
|
||||
todo("build this one.");
|
||||
|
||||
11
tests/.tests/SuccessOnly.php
Normal file
11
tests/.tests/SuccessOnly.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
it('can pass with comparison', function () {
|
||||
expect(true)->toEqual(true);
|
||||
});
|
||||
|
||||
test('can also pass', function () {
|
||||
expect("string")->toBeString();
|
||||
});
|
||||
@ -1,32 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Pest\Logging\TeamCity;
|
||||
use PHPUnit\Framework\AssertionFailedError;
|
||||
use PHPUnit\Framework\TestResult;
|
||||
use PHPUnit\Framework\TestSuite;
|
||||
use PHPUnit\Framework\Warning;
|
||||
use PHPUnit\TextUI\DefaultResultPrinter;
|
||||
test('visual snapshot of team city', function (string $testFile) {
|
||||
$testsPath = dirname(__DIR__)."/.tests/$testFile";
|
||||
|
||||
beforeEach(function () {
|
||||
file_put_contents(__DIR__.'/output.txt', '');
|
||||
});
|
||||
$snapshot = implode(DIRECTORY_SEPARATOR, [
|
||||
dirname(__DIR__),
|
||||
'.snapshots',
|
||||
"$testFile.inc",
|
||||
]);
|
||||
|
||||
it('is can successfully call all public methods', function () {
|
||||
$teamCity = new TeamCity(__DIR__.'/output.txt', false, DefaultResultPrinter::COLOR_ALWAYS);
|
||||
expect($teamCity::isPestTest($this))->toBeTrue();
|
||||
$teamCity->startTestSuite(new TestSuite());
|
||||
$teamCity->startTest($this);
|
||||
$teamCity->addError($this, new Exception('Don\'t worry about this error. Its purposeful.'), 0);
|
||||
$teamCity->addFailure($this, new AssertionFailedError('Don\'t worry about this error. Its purposeful.'), 0);
|
||||
$teamCity->addWarning($this, new Warning(), 0);
|
||||
$teamCity->addIncompleteTest($this, new Exception(), 0);
|
||||
$teamCity->addRiskyTest($this, new Exception(), 0);
|
||||
$teamCity->addSkippedTest($this, new Exception(), 0);
|
||||
$teamCity->endTest($this, 0);
|
||||
$teamCity->printResult(new TestResult());
|
||||
$teamCity->endTestSuite(new TestSuite());
|
||||
})->skip('Not supported yet.');
|
||||
$output = function () use ($testsPath) {
|
||||
$process = (new Symfony\Component\Process\Process(
|
||||
['php', 'bin/pest', '--teamcity', $testsPath],
|
||||
dirname(__DIR__, levels: 2),
|
||||
[
|
||||
'EXCLUDE' => 'integration',
|
||||
'REBUILD_SNAPSHOTS' => false,
|
||||
'PARATEST' => 0,
|
||||
'COLLISION_IGNORE_DURATION' => 'true',
|
||||
'FLOW_ID' => '1234',
|
||||
],
|
||||
));
|
||||
|
||||
afterEach(function () {
|
||||
unlink(__DIR__.'/output.txt');
|
||||
});
|
||||
$process->run();
|
||||
|
||||
return $process->getOutput();
|
||||
};
|
||||
|
||||
if (getenv('REBUILD_SNAPSHOTS')) {
|
||||
$outputContent = explode("\n", $output());
|
||||
|
||||
file_put_contents($snapshot, implode("\n", $outputContent));
|
||||
} elseif (! getenv('EXCLUDE')) {
|
||||
$output = explode("\n", $output());
|
||||
|
||||
expect(implode("\n", $output))->toEqual(file_get_contents($snapshot));
|
||||
}
|
||||
})->with([
|
||||
'Failure.php',
|
||||
'SuccessOnly.php',
|
||||
])->skip(! getenv('REBUILD_SNAPSHOTS') && getenv('EXCLUDE'));
|
||||
|
||||
Reference in New Issue
Block a user