Ejemplo n.º 1
0
 /**
  * Collect code coverage statistics and profile memory.
  *
  * If your code is running out of memory, you can use this to see which
  * tests are consuming lots.  This can often happen with poorly
  * created @dataProvider methods.  You can extend the profiling to do
  * any sort of thing you'd like.  See startProfile() and stopProfile().
  *
  *    PROFILE=1 phpunit myTest.php
  *
  * Code coverage statistics can be generated automatically too.  This
  * uses some custom code coverage tools, but you can start any coverage
  * collection code you'd like by modifying startCoverage() and
  * stopCoverage().
  *
  *    COVERAGE=1 phpunit myTest.php
  */
 public function runTest()
 {
     $profileMemory = getenv('PROFILE_MEMORY');
     $doCoverage = getenv('COVERAGE');
     $thrownException = null;
     if ($profileMemory) {
         $profile = PHPToolsTestUtil::startProfile();
     }
     if ($doCoverage) {
         $coverage = PHPToolsTestUtil::startCoverage($this);
     }
     try {
         $result = parent::runTest();
     } catch (Exception $ex) {
         $thrownException = $ex;
     }
     if ($doCoverage) {
         PHPToolsTestUtil::stopCoverage($coverage);
     }
     if ($profileMemory) {
         PHPToolsTestUtil::stopProfile($this, $this->getTestCasePrivate('name'), $this->getTestCasePrivate('dataName'), $profile);
     }
     if (!is_null($thrownException)) {
         throw $thrownException;
     }
     return $result;
 }