Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jbtje's avatar
Level 3

Running Unit test in PHPStorm, but not showing the web response

I've decided to give Test Driven Development a try. So far, so good, however while developing an API for my site, I do run into the problem that the test is false so now and than. Once the test fails, only little information is provided for example:

Expected status code 200 but received 422. Failed asserting that false is true.

It also gives the line of the test that failed, however it does not give the response of the API. In this case 422 is a valid JSON response, without exceptions. The JSON response is that the user needs to provide a email/password in order to login.

I already found on this forums that you can export the logs to the command line by adding the following line to web.php (it is a kind of hack... but well)

Log::useFiles( 'php://stderr' );

Now my question is: Is it possible to show the webresponse in the command line when the test fails?

I'm using Laravel 5.4

0 likes
1 reply
ejdelmonico's avatar
Level 53

@jbtje Personally, I don't use testing within phpstorm unless its just simple testing that I expect to pass. For some reason, phpstorm doesn't give very good failure message. The way I do it is run the testing with phpstorm, if it fails with an obscure message, I run the test again in the terminal. Jeffrey explains a little about this issue in the Forum series.

1 like

Please or to participate in this conversation.