Phpunit extension kit

I extended PHPUnit_Framework_TestSuite to overwrite the setUp and tearDown method because I need PHPUnit to do some operation before and after the test suite. (The test is in multiple TestCase classes.)

class MyTestSuite extends PHPUnit_Framework_TestSuite {

    protected function setUp()
    {
        //do some stuff before all tests are run
    }

    protected function tearDown()
    {
        //do some stuff after all tests are run
    }
}

      

How in the xml config file I tell phpunit to use this TestSuite class and then bind the testCase class to it? All I can find is an example like this, which doesn't sound like specifying which test suite class phpunit should use.

<phpunit>
  <testsuites>
    <testsuite name="money">
      <file>tests/IntlFormatterTest.php</file>
      <file>tests/MoneyTest.php</file>
      <file>tests/CurrencyTest.php</file>
    </testsuite>
  </testsuites>
</phpunit>

      

+3


source to share


1 answer


In https://phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.testsuites have this information:

The <testsuites> element and its one or more tests. children can to compose a test suite from test suites and test cases.

I am using Ecomdev_PHPUnit

in Magento, which subclasses how you want, look at your xml:



<testsuite name="Magento Test Suite">
     <file>app/code/community/EcomDev/PHPUnit/Test/Suite.php</file>
</testsuite>

      

So just hand over the complete test suite I guess!

0


source







All Articles