Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
806 views
in Technique[技术] by (71.8m points)

unit testing - How to exclude file from PHPUnit test suite in xml config?

I have following, very simple, XML config for PHPUnit:

<phpunit bootstrap="/_tests/TestAutoload.php">
    <testsuites>
        <testsuite name="Unit Tests">
            <directory suffix=".php">_tests</directory>
        </testsuite>
    </testsuites>
</phpunit>

How to exclude certain file in this directory from test suite? I tried <exclude> and <blacklist>, but it doesn't seem to work in this context. Also couldn't find any other documentation than phpunit.de one, which doesn't mention anything about it. Else than that, this config works perfectly.

question from:https://stackoverflow.com/questions/2736343/how-to-exclude-file-from-phpunit-test-suite-in-xml-config

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To exclude the file name TestCase.php.

add this to your phpunit.xml

<testsuites>
    <testsuite name="BLABLA">
        <directory suffix=".php">./tests</directory>
        <exclude>./tests/TestCase.php</exclude>
    </testsuite>
</testsuites>

Here is an additional excerpt from a real-live test-suite I can confirm it working with:

...
    <testsuites>
        <testsuite name="n98-magerun-tests">
            <directory>./tests</directory>
            <exclude>tests/N98/Magento/Command/Installer/UninstallCommandTest.php</exclude>
        </testsuite>
    ...

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...