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 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...