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 run tests in parallel with PHPUnit?
- How to use hooks in PHPUnit?
- What are PHPUnit required extensions
- How to use the PHPUnit Framework TestCase?
- How to run PHPUnit in quiet mode?
- How to show warnings in PHPUnit?
- How to load fixtures with PHPUnit?
- How to use a listener with PHPUnit?
- How to stop PHPUnit on failure?
See more codes...