Avatar ·

How to run one specific test in PHPUnit?

Hello everyone! I'm new to PHPUnit and can't figure out how to run individual tests. I have a large test class UserServiceTest.php with a dozen methods. When I run phpunit in the console, it runs all tests at once. This takes a very long time, especially when I'm editing one specific method and want to quickly test only it.

\n\n

Here's an example of my test class:

\n\n
<?php\nuse PHPUnit\\Framework\\TestCase;\n\nclass UserServiceTest extends TestCase\n{\n    public function testCreateUser(): void\n    {\n        // ... lots of code\n    }\n\n    public function testUpdateUser(): void\n    {\n        // ... lots of code\n    }\n\n    public function testDeleteUser(): void\n    {\n        // ... lots of code that I'm currently editing\n    }\n}\n?&