diff --git a/src/Concerns/Testable.php b/src/Concerns/Testable.php index 273dfb75..a962edf3 100644 --- a/src/Concerns/Testable.php +++ b/src/Concerns/Testable.php @@ -185,6 +185,10 @@ trait Testable { TestSuite::getInstance()->test = $this; + $method = TestSuite::getInstance()->tests->get(self::$__filename)->getMethod($this->name()); + + $this->__description = self::$__latestDescription = $this->dataName() ? $method->description.' with '.$this->dataName() : $method->description; + parent::setUp(); $beforeEach = TestSuite::getInstance()->beforeEach->get(self::$__filename)[1]; @@ -234,10 +238,6 @@ trait Testable */ private function __resolveTestArguments(array $arguments): array { - $method = TestSuite::getInstance()->tests->get(self::$__filename)->getMethod($this->name()); - - $this->__description = self::$__latestDescription = $this->dataName() ? $method->description.' with '.$this->dataName() : $method->description; - $underlyingTest = Reflection::getFunctionVariable($this->__test, 'closure'); $testParameterTypes = array_values(Reflection::getFunctionArguments($underlyingTest)); diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 45efb415..3be4a48c 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -1052,6 +1052,7 @@ ✓ it can return an array of all test suite filenames PASS Tests\Visual\BeforeEachTestName + ✓ description ✓ latest description PASS Tests\Visual\Collision @@ -1084,4 +1085,4 @@ WARN Tests\Visual\Version - visual snapshot of help command output - Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 742 passed (1787 assertions) \ No newline at end of file + Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 743 passed (1788 assertions) \ No newline at end of file diff --git a/tests/Visual/BeforeEachTestName.php b/tests/Visual/BeforeEachTestName.php index 0153c7bc..7206ec8c 100644 --- a/tests/Visual/BeforeEachTestName.php +++ b/tests/Visual/BeforeEachTestName.php @@ -1,6 +1,13 @@ $this->latestDescription = self::$__latestDescription); +beforeEach(function () { + $this->description = $this->__description; + $this->latestDescription = self::$__latestDescription; +}); + +test('description', function () { + expect($this->description)->toBe('description'); +}); test('latest description', function () { expect($this->latestDescription)->toBe('latest description');