phpunitHow to run only certain methods in PHPUnit?
You can run only certain methods in PHPUnit by using the --filter
option.
For example, to run only the testAdd()
method in the CalculatorTest
class, you can use the following command:
phpunit --filter testAdd CalculatorTest
This will run only the testAdd()
method in the CalculatorTest
class.
The parts of the command are:
phpunit
: the command to run PHPUnit--filter
: the option to specify which method to runtestAdd
: the name of the method to runCalculatorTest
: the name of the class containing the method
For more information, see the PHPUnit documentation.
More of Phpunit
- How to skip a PHPUnit test?
- How to mock a method with different arguments in PHPUnit?
- How to run tests in parallel with PHPUnit?
- How to run all PHPUnit tests?
- How to mock a static method with PHPUnit?
- How to mock a query builder with PHPUnit?
- How to launch one test with PHPUnit?
- How to check if a JSON contains a value in PHPUnit?
- How to use hooks in PHPUnit?
See more codes...