dk4210's avatar

Dusk - Calling a specific test

Hello Guys,

How would I call a specific test.

For example if I create a test called MyTest

php artisan dusk:make MyTest

I then update the test with the testing code.

How can I call the test from the command line?

I tried something like this

php artisan dusk Mytest

That doesn't work. Maybe I'm missing something.

Thanks for the help.

0 likes
8 replies
gcwilliams's avatar

I believe you can just do

php artisan dusk --filter=<name_of_method>

dk4210's avatar

@tomi I saw group but not sure how to implement it. I did read that it the docs.

In my mind when I create a new test via artisan that it seems like I should be able to point to that specific test, instead what happens is when I run artisan dusk, it runs all the tests. Just trying to. understand.

@gcwilliams I see what your saying to create multi methods and point to them, but I would rather point to different test cases,

Thank you both for the help.

dk4210's avatar

So why create more test file? Maybe for running all of them consecutively?

MikeHopley's avatar

I'm not using Dusk yet, but I think you should just be able to use the full path from the tests folder:

php artisan dusk tests/Browser/specific-test.php

...and I guess you can probably leave off the .php too.

gcwilliams's avatar

All Dusk is doing is passing the options after the dusk command to phpunit. You can run any phpunit command option, including --groupor --filter. Filter can filter via the individual test name or you can filter by the entire test class name. Example:

class CreatePostTest extends TestCase
{

    /** @test */
    public function guests_may_not_create_posts()
    {

    }

}

You can filter by guests_may_not_create_posts or CreatePostTest

Please or to participate in this conversation.