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
@testannotation: marks a test as a test@ignoreannotation: marks a test as skipped
Helpful links
More of Phpunit
- How to run tests in parallel with PHPUnit?
- How to show warnings in PHPUnit?
- How to stop PHPUnit on failure?
- How to mock a static method with PHPUnit?
- How to skip a PHPUnit test?
- What are PHPUnit required extensions
- How to mock a private method in PHPUnit?
- How to mock a query builder with PHPUnit?
- How to mock a method with different arguments in PHPUnit?
- How to use hooks in PHPUnit?
See more codes...