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 show warnings in PHPUnit?
- How to clear the PHPUnit cache?
- How to log to the console with PHPUnit?
- How to use PHPUnit json assert?
- What are PHPUnit required extensions
- How to stop PHPUnit on failure?
- How to mock a method with different arguments in PHPUnit?
- How to test private methods in PHPUnit?
- How to install PHPUnit with a PHAR file?
See more codes...