@covers

@covers

The @covers annotation can be used in the test code to specify which method(s) a test method wants to test:

/**
 * @covers BankAccount::getBalance
 */
public function testBalanceIsInitiallyZero()
{
    $this->assertEquals(0, $this->ba->getBalance());
}

If provided, only the code coverage information for the specified method(s) will be considered.

Table B.1 shows the syntax of the @covers annotation.

Table B.1. Annotations for specifying which methods are covered by a test

Annotation Description
@covers ClassName::methodName Specifies that the annotated test method covers the specified method.
@covers ClassName Specifies that the annotated test method covers all methods of a given class.
@covers ClassName<extended> Specifies that the annotated test method covers all methods of a given class and its parent class(es) and interface(s).
@covers ClassName::<public> Specifies that the annotated test method covers all public methods of a given class.
@covers ClassName::<protected> Specifies that the annotated test method covers all protected methods of a given class.
@covers ClassName::<private> Specifies that the annotated test method covers all private methods of a given class.
@covers ClassName::<!public> Specifies that the annotated test method covers all methods of a given class that are not public.
@covers ClassName::<!protected> Specifies that the annotated test method covers all methods of a given class that are not protected.
@covers ClassName::<!private> Specifies that the annotated test method covers all methods of a given class that are not private.
@covers ::functionName Specifies that the annotated test method covers the specified global function.
doc_PHPUnit
2016-10-16 15:37:29
Comments
Leave a Comment

Please login to continue.