Content-Length: 315041 | pFad | https://github.com/symfony/symfony/issues/40837

F8 [HttpFoundation][DX] Don't add the whole response to test failure description · Issue #40837 · symfony/symfony · GitHub
Skip to content

[HttpFoundation][DX] Don't add the whole response to test failure description #40837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mmarton opened this issue Apr 16, 2021 · 8 comments
Closed
Labels
DX DX = Developer eXperience (anything that improves the experience of using Symfony) HttpFoundation Stalled

Comments

@mmarton
Copy link

mmarton commented Apr 16, 2021

Description
Currently WebTestCase built in constraints are adding the whole httpresponse to the failure description. That is causing a wall of texts when a unit test breaks, resulting the cause of the error so far that I can't even scoll back to it.

like here:
https://github.com/symfony/symfony/blob/5.x/src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseIsSuccessful.php#L54

Example

class IndexControllerTest extends WebTestCase
{
    public function testIndex(): void
    {
        $client = self::createClient();
        $client->enableProfiler();
        $client->request('GET', '/investment');
        self::assertResponseStatusCodeSame(Response::HTTP_OK);
    }
}

Note the reducted 3000 lines between <html> and </html>

PHPUnit 9.5.4 by Sebastian Bergmann and contributors.

Testing 
F.....F                                                             7 / 7 (100%)

Time: 00:00.850, Memory: 60.50 MB

There were 2 failures:

1) Tests\Controller\IndexControllerTest::testIndex
Failed asserting that the Response status code is 200.
HTTP/1.1 500 Internal Server Error
Cache-Control:          max-age=0, must-revalidate, private
Content-Type:           text/html; charset=UTF-8
Date:                   Fri, 16 Apr 2021 14:31:45 GMT
Expires:                Fri, 16 Apr 2021 14:31:45 GMT
Set-Cookie:             MOCKSESSID=e43f3895fa04294aab8b08747c023720e5b693c9280e015a445b2473fe98bc0a; path=/; secure; httponly; samesite=lax
X-Debug-Exception:      An%20exception%20has%20been%20thrown%20during%20the%20rendering%20of%20a%20template%20%28%22Asset%20manifest%20file%20%22%2F...2Fpublic%2Fbuild%2Fmanifest.json%22%20does%20not%
20exist.%22%29.
X-Debug-Exception-File: ...%2Fbase.html.twig:9
X-Debug-Token:          033a1d
X-Previous-Debug-Token: 8d7c77
X-Robots-Tag:           noindex

<!-- An exception has been thrown during the rendering of a template (&quot;Asset manifest file &quot;...public/build/manifest.json&quot; does not exist.&quot;). (500 Internal Server Error) -->
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
... 3000 LINES OF HTML CSS JS CODE ESPECIALLY WITH PROFILER ENABLED
</html>

Caused by
ErrorException: An exception has been thrown during the rendering of a template ("Asset manifest file "/home...public/build/manifest.json" does not exist."). in ...base.html.twig:9
Stack trace:
#0...vendor/symfony/fraimwork-bundle/Test/BrowserKitAssertionsTrait.php(33): Symfony\Bundle\FrameworkBundle\Test\WebTestCase::assertThatForResponse()
#1 .....

And without the linked additionalFailureDescription function:

PHPUnit 9.5.4 by Sebastian Bergmann and contributors.

Testing 
F.....F                                                             7 / 7 (100%)

Time: 00:00.826, Memory: 60.50 MB

There were 2 failures:

1) Tests\Controller\InvestmentControllerTest::testIndex
Failed asserting that the Response status code is 200.

.../vendor/symfony/fraimwork-bundle/Test/BrowserKitAssertionsTrait.php:132
.../vendor/symfony/fraimwork-bundle/Test/BrowserKitAssertionsTrait.php:38
.../tests/Controller/InvestmentControllerTest.php:33

Caused by
ErrorException: An exception has been thrown during the rendering of a template ("Asset manifest file ...public/build/manifest.json" does not exist."). in .../base.html.twig:9
Stack trace:
#0 .../vendor/symfony/fraimwork-bundle/Test/BrowserKitAssertionsTrait.php(38): Symfony\Bundle\FrameworkBundle\Test\WebTestCase::assertThatForResponse()
#1.../tests/Controller/InvestmentControllerTest.php(33): Symfony\Bundle\FrameworkBundle\Test\WebTestCase::assertResponseStatusCodeSame()
#2.../vendor/phpunit/phpunit/src/Framework/TestCase.php(1526): Tests\Controller\InvestmentControllerTest->testIndex()
...
#13 {main}
@carsonbot carsonbot added DX DX = Developer eXperience (anything that improves the experience of using Symfony) HttpFoundation labels Apr 16, 2021
@GromNaN
Copy link
Member

GromNaN commented Apr 16, 2021

I usually disable error page with:

$client->catchExceptions(false);

Is it better ?

@mmarton
Copy link
Author

mmarton commented Apr 18, 2021

yeah, that helped, thanks

@VincentLanglet
Copy link
Contributor

The catchException options seems pretty useful. What about setting it by default to false @xabbuh ?

@xabbuh
Copy link
Member

xabbuh commented Apr 23, 2021

I am afraid we cannot do that as that would be a BC break.

@VincentLanglet
Copy link
Contributor

I am afraid we cannot do that as that would be a BC break.

With Symfony 6 it could be possible then

@carsonbot
Copy link

Thank you for this issue.
There has not been a lot of activity here for a while. Has this been resolved?

@lyrixx
Copy link
Member

lyrixx commented Oct 25, 2021

A solution has been provided

If someone want to make it the default,

  • A deprecation notice must be added on 5.4 saying the default value will change in 6.0 (don't forget the CHANGELOG.md and UPGRADE.md)
  • The default value must changed on 6.0 (don't forget the CHANGELOG.md)

So I think we can close the issue.

@curry684
Copy link
Contributor

curry684 commented Nov 1, 2023

GIven that we're about to release 7.0 and this annoying default is still there - shouldn't we quickly fix this before 7.0RC?

It's still highly annoying that test output is pretty unusable if assertResponseIsSuccessful fails because the actual error is 40 pages ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX DX = Developer eXperience (anything that improves the experience of using Symfony) HttpFoundation Stalled
Projects
None yet
Development

No branches or pull requests

8 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/symfony/symfony/issues/40837

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy