hoaproject / Test

The Hoa\Test library.
https://hoa-project.net/
11 stars 10 forks source link

Test: Restrict code coverage to current library #86

Closed Hywan closed 7 years ago

Hywan commented 7 years ago

This patch automatically restricts the code coverage score to the current library. By default, atoum can exclude some namespaces, but we want to exclude all namespaces except the current tested one. To achieve this, we create a new coverage score, which extends the default atoum\score\coverage class. The isExcluded method is extended to support the restrictedNamespace attribute.

The restrictNamespace method is also new. It adds a namespace separator (backslash) at the end of the restrictedNamepace to avoid a prefix collision. For instance: Foo\Bar will not collide withFoo\Barz if we test the latter starts with Foo\Bar\.

If the namespace is not excluded, we re-use the parent isExcluded method to get all the default features from atoum.

On Hoa\Acl, the code coverage was reporting scores for Hoa\Acl and Hoa\Exception. With this patch, it reports scores only for Hoa\Acl, which is the expected behavior in our case.

Address https://github.com/hoaproject/Acl/pull/20.