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 mock a method with different arguments in PHPUnit?
- How to run tests in parallel with PHPUnit?
- How to run all PHPUnit tests?
- How to run only certain methods in PHPUnit?
- 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...