/**
  * Add test result node, if it does not yet exist.
  *
  * @param   unittest.TestCase case
  * @return  xml.Node
  */
 protected function testNode(TestCase $case)
 {
     $class = $case->getClass();
     if (!$this->classes->containsKey($class)) {
         $this->classes[$class] = $this->tree->addChild(new Node('testsuite', NULL, array('name' => $class->getName(), 'file' => $this->uriFor($class), 'tests' => 0, 'failures' => 0, 'errors' => 0, 'skipped' => 0, 'time' => 0)));
     }
     return $this->classes[$class];
 }
Exemplo n.º 2
0
 /**
  * Run a single test
  *
  * @param   unittest.TestCase test
  * @return  unittest.TestResult
  * @throws  lang.IllegalArgumentException in case given argument is not a testcase
  * @throws  lang.MethodNotImplementedException in case given argument is not a valid testcase
  */
 public function runTest(TestCase $test)
 {
     $class = $test->getClass();
     if (!$class->hasMethod($test->name)) {
         throw new MethodNotImplementedException('Test method does not exist', $test->name);
     }
     $this->notifyListeners('testRunStarted', array($this));
     // Run the single test
     $result = new TestResult();
     try {
         $this->beforeClass($class);
         $this->runInternal($test, $result);
         $this->afterClass($class);
     } catch (PrerequisitesNotMetError $e) {
         $this->notifyListeners('testSkipped', array($result->setSkipped($test, $e, 0.0)));
     }
     $this->notifyListeners('testRunFinished', array($this, $result));
     return $result;
 }