I have a PHPUnit test that’s failing but the test output is hiding important part of the failed data. How to make the whole data visible?
To demonstrate the issue, here’s a mock test UnitTest.php
:
<?php
class UnitTest extends PHPUnitFrameworkTestCase
{
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.");
}
}
When I run it as phpunit UnitTest.php
I get following output:
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.'
)
How to make the full string visible in PHPUnit output so that I can see the word HERE
in the console? I couldn’t find any documentation that would have described this kind of shortening or clipping the asserted data and I don’t want any shortening or clipping here.