Youssef_'s avatar

Run test from controller ?

Hi all,

I was wondering if it is possible to run a test procedure from a controller or anywhere else in the app ?

Thanks a lot,

Youssef.

0 likes
3 replies
topvillas's avatar

You could create an artisan command that runs phpunit and call it using the Artisan facade.

Youssef_'s avatar

To be honest, i wanted to use laravel/dusk within a controller

bastman69's avatar

Hi Youssef_ depends on you try to test. If your method contains business logic it would be better to move that logic to the related model or in its own class and test it with phpunit. if it is just a ui test and you are interested for the result you can use dusk. Of course that is my point of you. i suggest you to watch the testing series that jeffrey offers us.

Please or to participate in this conversation.