You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I have long strings in an array that's passed to assertEquals() and the values are not equal, the emitted failure message clips away important part of the string.
How to reproduce
mkdir test&&cdtest
wget -O phpunit https://phar.phpunit.de/phpunit-10.phar
cat << 'EOF' > UnitTest.php<?phpclass UnitTest extends PHPUnit\Framework\TestCase{ public function testAssertingArrays() { $mock_testresult = array( 0 => "Some short string", 1 => "Some really long string that just keeps going and going and going but contains important clue HERE about why this whole test failed.", ); $this->assertEquals($mock_testresult, array(), "Expected empty array but got non-empty array."); }}EOF
php phpunit UnitTest.php
Current behavior
PHPUnit 10.5.20 by Sebastian Bergmann and contributors.
Runtime: PHP 8.1.2-1ubuntu2.17
F 1 / 1 (100%)
Time: 00:00.001, Memory: 24.79 MB
There was 1 failure:
1) UnitTest::testAssertingArrays
Expected empty array but got non-empty array.
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
- 0 => 'Some short string'
- 1 => 'Some really long string that ...ailed.'
)
/home/user/test/UnitTest.php:10
FAILURES!
Tests: 1, Assertions: 1, Failures: 1
Expected behavior
Otherwise same but the array offset 1 should show enough of the string to also see the word "HERE".
Additional information
I can see the whole string if I run php phpunit --debug UnitTest.php instead but the output is so verbose otherwise that it's hard to read. I'd rather see normal output but the whole string, but I couldn't find any documented feature to turn off this kind of string clipping/shortening.
The text was updated successfully, but these errors were encountered:
Wow, it would be super useful to not have this clipping at all.
I've so many cases where I see the clipping where I realize my "expected" actually is wrong and it would just speed up things if I can copypaste it from that output and carry on.
Summary
When I have long strings in an array that's passed to assertEquals() and the values are not equal, the emitted failure message clips away important part of the string.
How to reproduce
Current behavior
Expected behavior
Otherwise same but the array offset 1 should show enough of the string to also see the word "HERE".
Additional information
I can see the whole string if I run
php phpunit --debug UnitTest.php
instead but the output is so verbose otherwise that it's hard to read. I'd rather see normal output but the whole string, but I couldn't find any documented feature to turn off this kind of string clipping/shortening.The text was updated successfully, but these errors were encountered: