Skip to content
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

[ErrorHandler][FrameworkBundle] better error messages in failing tests #36003

Merged
merged 1 commit into from Mar 16, 2020

Conversation

@guillbdx
Copy link
Contributor

guillbdx commented Mar 9, 2020

Q A
Branch? master for features
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #32752
License MIT
Doc PR

Purpose of this PR is to enhance tests by giving a way to report an exception that occured during the processing of the request.

The ErrorHandler will add an X-Debug-Exception, and the assertThat() method of WebTestCase will throw an exception if this header exists and status code is 5xx.

In practice, this adds the "Caused by" section in this example:

Time: 374 ms, Memory: 20.00 MB

There was 1 failure:

1) App\Tests\Controller\HomeControllerTest::testC
Failed asserting that the Response has header "Content-Type" with value "application/json".

/srv/symfony/src/Symfony/Bundle/FrameworkBundle/Test/BrowserKitAssertionsTrait.php:132
/srv/symfony/src/Symfony/Bundle/FrameworkBundle/Test/BrowserKitAssertionsTrait.php:66
/srv/blog/tests/Controller/HomeControllerTest.php:29

Caused by
Exception: This a test exception. in /the/file.php:139
Stack trace:
[...]
@nicolas-grekas nicolas-grekas added this to the next milestone Mar 9, 2020
@guillbdx guillbdx changed the title Feature/32752 better error messages in failing tests [ErrorHandler][FrameworkBundle] better error messages in failing tests Mar 9, 2020
Copy link
Member

nicolas-grekas left a comment

Cool! No more blind errors when using this testing API \o/

Copy link
Member

yceruto left a comment

I added some comments, thank you!

@fabpot
fabpot approved these changes Mar 16, 2020
@fabpot

This comment has been minimized.

Copy link
Member

fabpot commented Mar 16, 2020

Thank you @guillbdx.

@fabpot fabpot merged commit 693cf11 into symfony:master Mar 16, 2020
1 of 3 checks passed
1 of 3 checks passed
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
fabbot.io Your code looks good.
Details
@sstok

This comment has been minimized.

Copy link
Contributor

sstok commented Mar 22, 2020

Nice! This was the one thing missing from the new testing assertions. Thanks for working on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

6 participants
You can’t perform that action at this time.