jbarotin's avatar

How to see the stack trace while executing unit test on REST API that don't work

Hello,

I'm trying to implement a REST API with lumen.

In order to validate my work. I wrote unit test thought phpunit. Sometime, an error occur (database constrains for example) in the REST API, that generate a "rich" web page in order to view the error in a browser.

But, I'm running my test in command line, I would prefer to get the stack without all this html formatting.

Do you think there a way to do that ? (log...)

0 likes
5 replies
shez1983's avatar
shez1983
Best Answer
Level 23

in laravel 5.5 there is a trait/func you can use in your tests that disableExceptions() google/see the docs

in previous version (or even 5.5) you can add an conditional in app/Exception.php where it says render()... just above it

say if env == testing throw ($e)

https://laracasts.com/series/whats-new-in-laravel-5-5/episodes/17 ->withoutExceptionHandling

(not sure if its available in lumen :s)

1 like
shez1983's avatar

so you mark your own answer as the correct one after I gave you the correct answer.. .. nice..

jbarotin's avatar

Hey don't be sad. You haven't really given the answer : you gave me a way to find myself the answer. And, it's what I did, and then I reply with the real answer to my question in order to help people that will had the same issue than me to find quicker a way to resolve it... and I'm not thinking that's what your answer is.

shez1983's avatar

i m not being sad - just irritated.. i gave you exactly what you asked for - your own solution doesnt HELP in anyway answer what your original post stated.. anyway.. life's too short & all that..

i even TOLD you to change the render func.. your answer is WRONG.. you dont do that..

jbarotin's avatar

Ok, my fault, I haven't fully understood your answer.

Please or to participate in this conversation.