hasandev's avatar

How to test specific test in Laravel.

I want to test something specifically in Laravel. Let's say, testUserTest(). I want to test only this. How can I do that instead to running test on everything?

2 likes
9 replies
da_Mask's avatar

You can also call a single test method like this:

php artisan test --filter UserTest::can_create_user

That could be more of what the OP was after.

18 likes
baumgars's avatar

@da_Mask this looks like the most elegant way. But, i want to test a method with curl involved inside. So my dev plattform is Windows and obviously curl does not exist under Windows. So i am using Ubuntu with WSL 2. But if i run the test, nothing happens. Like it looks like its running forever without moving forward. Also in your example UserTest, if it is down the folder hiearchy somewhere, how do you express the path?

Edit: it turned out it run, but takes a lot of time to start or maybe at that point something else was stuck because the next day it started up rather quickly. Other than that this syntax does not find tests. The tests begin with test_ and now the only thing i can see is wrong path. Is there a way to find out what is going wrong? Because --verbose option in phpunit 11.5 does not exist anymore.

Please or to participate in this conversation.