| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Unsure how to add a test for this as it only occurs on the failure of a test. I used the following test <?php
namespace Tests\Unit;
use Codeception\Test\Unit;
use PHPUnit\Framework\AssertionFailedError;
use Tests\Support\UnitTester;
class TestTest extends Unit {
protected UnitTester $tester;
public function test1(){
static::fail(':-(');
}
public function test2(){
$this->expectException(AssertionFailedError::class);
$this->tester->assertFalse(true);
}
}
Output before fix Codeception PHP Testing Framework v5.1.0 https://stand-with-ukraine.pp.ua Tests.Unit Tests (2) ------------------------------------------------------------------------------------------------------------- ✖ TestTest: Test1(0.01s) ✖ TestTest: Test2(0.00s) ---------------------------------------------------------------------------------------------------------------------------------- Time: 00:00.102, Memory: 16.87 MB There was 1 failure: 1) TestTest: Test2 Test tests/Unit/TestTest.php:test2 :-( #1 /usr/src/app/tests/Unit/TestTest.php:14 #2 /usr/src/app/vendor/bin/codecept:119 FAILURES! Tests: 2, Assertions: 2, Failures: 1. Output after fix Codeception PHP Testing Framework v5.1.0 https://stand-with-ukraine.pp.ua Tests.Unit Tests (2) ------------------------------------------------------------------------------------------------------------- ✖ TestTest: Test1(0.01s) ✔ TestTest: Test2(0.00s) ---------------------------------------------------------------------------------------------------------------------------------- Time: 00:00.087, Memory: 16.87 MB There was 1 failure: 1) TestTest: Test1 Test tests/Unit/TestTest.php:test1 :-( #1 /usr/src/app/tests/Unit/TestTest.php:14 #2 /usr/src/app/vendor/bin/codecept:119 FAILURES! Tests: 2, Assertions: 2, Failures: 1. |
Sorry, something went wrong.
|
Your change broke conditional assertions Codeception/src/Codeception/Scenario.php Line 79 in fcfa1d0 |
Sorry, something went wrong.
|
I think that the best way to compare if 2 variables contain the same test is to compare results of \Codeception\Test\Descriptor::getTestSignatureUnique(). if ($lastFailure && Descriptor::getTestSignatureUnique($lastFailure->getTest()) === Descriptor::getTestSignatureUnique($this)For ideas how to implement test for your change see Codeception/tests/cli/RunCest.php Lines 606 to 669 in fcfa1d0 Codeception/tests/cli/OrderCest.php Lines 16 to 75 in fcfa1d0 |
Sorry, something went wrong.
…comparison due to cloning
|
Thanks for the feedback, your suggestion fixed the broken test. I have also refactored to avoid the loop when not needed. I will look at adding a new test in the next few days |
Sorry, something went wrong.
|
I have added a test to cover the new change, and fixed the code style check that failed in the last run |
Sorry, something went wrong.
|
And fix pushed for the code style in the tests |
Sorry, something went wrong.
|
Released as 5.1.2 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This fixes #6716 which results in incorrect test failures being reported where a scenario has a failed assertion that has been caught within the test itself or via expectException