phpunitHow to ignore a test in PHPUnit?
To ignore a test in PHPUnit, you can use the @test
annotation. This annotation can be used to mark a test as skipped, which will cause it to be ignored when running the test suite.
Example
<?php
class MyTest extends \PHPUnit\Framework\TestCase
{
/**
* @test
*/
public function testSomething()
{
// ...
}
/**
* @test
*/
public function testSomethingElse()
{
// ...
}
/**
* @test
* @ignore
*/
public function testSomethingElse2()
{
// ...
}
}
The @test
annotation is used to mark a test as a test, and the @ignore
annotation is used to mark a test as skipped. This will cause the test to be ignored when running the test suite.
Code explanation
@test
annotation: marks a test as a test@ignore
annotation: marks a test as skipped
Helpful links
More of Phpunit
- How to skip a PHPUnit test?
- How to show warnings in PHPUnit?
- How to run PHPUnit in quiet mode?
- How to mock a method with different arguments in PHPUnit?
- How to mock a static method with PHPUnit?
- What are PHPUnit required extensions
- How to mock a query builder with PHPUnit?
- How to install PHPUnit with a PHAR file?
- How to install PHPUnit from Packagist?
See more codes...