phpunitHow to skip a PHPUnit test?
You can skip a PHPUnit test by using the @doesNotPerformAssertions
annotation. This annotation will cause the test to be marked as skipped, and no assertions will be performed.
Example
<?php
use PHPUnit\Framework\TestCase;
class MyTest extends TestCase
{
/**
* @doesNotPerformAssertions
*/
public function testSomething()
{
// No assertions will be performed
}
}
The @doesNotPerformAssertions
annotation can be used to skip a test without having to comment out the test code.
Code explanation
-
@doesNotPerformAssertions
annotation - This annotation is used to mark the test as skipped, and no assertions will be performed. -
Test code - The test code is the code that will be skipped.
Helpful links
More of Phpunit
- How to stop PHPUnit on failure?
- How to run PHPUnit in quiet mode?
- How to order tests with PHPUnit?
- How to install PHPUnit with a PHAR file?
- 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 disable color output in PHPUnit?
- How to mock an interface in PHPUnit?
See more codes...