PHPUnit – Test Suit with XML file

In this article, we will see how to create a test suit with an xml file. In our previous example, we have created a file system based test suit. One of the drawback of the file system based test suit is that, we don’t have any control over the order of execution of test case files. In the case of xml based test suit, we can define the order of execution test case files in an xml file.

1. Create a file called phpunit.xml in the root of the directory with the test case files

<phpunit>
  <testsuites>
    <testsuite name="Calculator">
      <file>tests/CalculatorWithFixtureTest.php</file>
      <file>tests/CalculatorTest.php</file>
    </testsuite>
  </testsuites>
</phpunit>

2. Run the test suit

Execute the given below command at the root of the project directory.

$ ./vendor/bin/phpunit --testdox

The result is given below :

Comments on this post

No comments.

Leave a Reply

Your email address will not be published. Required fields are marked *

Trackbacks and Pinbacks on this post

No trackbacks.

TrackBack URL