예제 #1
0
파일: Excel.php 프로젝트: slince/mechanic
 /**
  * 生成单元测试的sheet
  * @param TestSuite $testSuite
  * @return PHPExcel_Worksheet
  * @throws \PHPExcel_Exception
  */
 protected function makeTestSuiteSheet(TestSuite $testSuite)
 {
     $sheet = new PHPExcel_Worksheet($this->getExcel(), substr($testSuite->getName(), 0, 20));
     $rows = [];
     foreach ($testSuite->getTestCases() as $testCase) {
         $reportTable = $this->getTestCaseTable($testCase);
         $rows[] = [$testCase->getName()];
         $rows = array_merge($rows, [$reportTable->getHeaders()], $reportTable->getRows());
         $rows[] = [];
         if ($messages = $testCase->getTestCaseReport()->getMessages()) {
             $rows[] = [__("Messages"), implode("\r\n", $messages)];
             $rows[] = [];
         }
     }
     $sheet->fromArray($rows);
     return $sheet;
 }
예제 #2
0
 /**
  * 执行测试套件
  * @param TestSuite $testSuite
  */
 protected function runTestSuite(TestSuite $testSuite)
 {
     //给TestSuite传参
     $testSuite->setMechanic($this);
     $this->dispatcher->dispatch(EventStore::TEST_SUITE_EXECUTE, new Event(EventStore::TEST_SUITE_EXECUTE, $this, ['testSuite' => $testSuite]));
     foreach ($testSuite->getTestCases() as $testCase) {
         $this->runTestCase($testCase);
         $testSuite->getTestSuiteReport()->addTestCaseReport($testCase->getTestCaseReport());
     }
     $this->dispatcher->dispatch(EventStore::TEST_SUITE_EXECUTED, new Event(EventStore::TEST_SUITE_EXECUTED, $this, ['testSuite' => $testSuite]));
 }