From 4b1cad2493287647b362029457cfd0f03913eaa7 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 14 Mar 2023 13:06:42 +0000 Subject: [PATCH] fix: description when before each fails --- src/Concerns/Testable.php | 2 -- tests/.snapshots/Failure.php.inc | 4 ++-- tests/.snapshots/success.txt | 5 ++++- tests/Visual/BeforeEachTestName.php | 7 +++++++ 4 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 tests/Visual/BeforeEachTestName.php diff --git a/src/Concerns/Testable.php b/src/Concerns/Testable.php index 77964d3c..e6e44488 100644 --- a/src/Concerns/Testable.php +++ b/src/Concerns/Testable.php @@ -174,8 +174,6 @@ trait Testable */ protected function setUp(): void { - $this->__description = self::$__latestDescription = $this->name(); - TestSuite::getInstance()->test = $this; parent::setUp(); diff --git a/tests/.snapshots/Failure.php.inc b/tests/.snapshots/Failure.php.inc index ba28d46f..419c3b5d 100644 --- a/tests/.snapshots/Failure.php.inc +++ b/tests/.snapshots/Failure.php.inc @@ -1,6 +1,6 @@ ##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:342|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:274|nat src/Support/ExceptionTrace.php:28|nat src/Concerns/Testable.php:274|nat src/Concerns/Testable.php:217|nat src/Kernel.php:84' 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:342|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:272|nat src/Support/ExceptionTrace.php:28|nat src/Concerns/Testable.php:272|nat src/Concerns/Testable.php:215|nat src/Kernel.php:84' 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'] @@ -9,7 +9,7 @@ ##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:100|nat src/Concerns/Testable.php:274|nat src/Support/ExceptionTrace.php:28|nat src/Concerns/Testable.php:274|nat src/Concerns/Testable.php:217|nat src/Kernel.php:84' flowId='1234'] +##teamcity[testFailed name='it can fail' message='oh noo' details='at tests/.tests/Failure.php:18|nat src/Factories/TestCaseMethodFactory.php:100|nat src/Concerns/Testable.php:272|nat src/Support/ExceptionTrace.php:28|nat src/Concerns/Testable.php:272|nat src/Concerns/Testable.php:215|nat src/Kernel.php:84' 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'] diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 90b43c9f..bde61d13 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -908,6 +908,9 @@ ✓ it alerts users about tests with arguments but no input ✓ it can return an array of all test suite filenames + PASS Tests\Visual\BeforeEachTestName + ✓ latest description + PASS Tests\Visual\Help ✓ visual snapshot of help command output @@ -933,4 +936,4 @@ PASS Tests\Visual\Version ✓ visual snapshot of help command output - Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 18 skipped, 638 passed (1571 assertions) \ No newline at end of file + Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 18 skipped, 639 passed (1572 assertions) \ No newline at end of file diff --git a/tests/Visual/BeforeEachTestName.php b/tests/Visual/BeforeEachTestName.php new file mode 100644 index 00000000..0153c7bc --- /dev/null +++ b/tests/Visual/BeforeEachTestName.php @@ -0,0 +1,7 @@ + $this->latestDescription = self::$__latestDescription); + +test('latest description', function () { + expect($this->latestDescription)->toBe('latest description'); +});