Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a specific phpunit xml testsuite?

Tags:

xml

phpunit

how can i choose a specific testsuite to be executed?

$ phpunit --configuration config.xml

config.xml:

<testsuites>     <testsuite name="Library">         <directory>library</directory>     </testsuite>     <testsuite name="XXX_Form">         <file>library/XXX/FormTest.php</file>         <directory>library/XXX/Form</directory>     </testsuite> </testsuites> 
like image 451
Andreas Linden Avatar asked Sep 08 '10 20:09

Andreas Linden


People also ask

How do I run a PHPUnit test case?

How to Run Tests in PHPUnit. You can run all the tests in a directory using the PHPUnit binary installed in your vendor folder. You can also run a single test by providing the path to the test file. You use the --verbose flag to get more information on the test status.

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

The <phpunit> Element.

What is PHPUnit testing?

PHPUnit is a unit testing framework for the PHP programming language. It is an instance of the xUnit architecture for unit testing frameworks that originated with SUnit and became popular with JUnit. PHPUnit was created by Sebastian Bergmann and its development is hosted on GitHub.


1 Answers

Here's the code as if PHPUnit 3.7.13

$ phpunit --configuration config.xml --testsuite Library $ phpunit --configuration config.xml --testsuite XXX_Form 

If you want to run a group of the test suites then you can do this

<testsuites>   <testsuite name="Library">     <directory>library</directory>   </testsuite>   <testsuite name="XXX_Form">     <file>library/XXX/FormTest.php</file>     <directory>library/XXX/Form</directory>   </testsuite>   <testsuite name="Both">     <directory>library</directory>     <file>library/XXX/FormTest.php</file>     <directory>library/XXX/Form</directory>   </testsuite> </testsuites> 

Then

$ phpunit --configuration config.xml --testsuite Both 

Unfortunately PHPUnit currently does not support nested testsuites like this

<testsuites>     <testsuite name="Both">       <testsuite name="Library">         <directory>library</directory>       </testsuite>       <testsuite name="XXX_Form">         <file>library/XXX/FormTest.php</file>         <directory>library/XXX/Form</directory>       </testsuite>   </testsuite> </testsuites> 

So if you wanted to run groups of test suites this way you have to have xml configuration duplication!

like image 117
Josh Woodcock Avatar answered Sep 28 '22 03:09

Josh Woodcock