Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 441
Ondrej Slinták Avatar asked Apr 29 '10 10:04

Ondrej Slinták


People also ask

What is the PHPUnit XML configuration file used to organize tests?

The <phpunit> Element.

What are PHPUnit fixtures?

In Testing array operations with PHPUnit, the fixture was the array that is stored in the $stack variable. Most of the time, though, the fixture will be more complex than a simple array, and the amount of code needed to set it up will grow accordingly.

Is PHPUnit a framework?

PHPUnit is a programmer-oriented testing framework for PHP. It is an instance of the xUnit architecture for unit testing frameworks. The currently supported versions are PHPUnit 9 and PHPUnit 8.


1 Answers

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>     ... 
like image 162
Mahmoud Zalt Avatar answered Sep 18 '22 16:09

Mahmoud Zalt