예제 #1
0
 /**
  * Executing prepared scenario.
  *
  * @param string $testMethodName
  * @return void
  */
 protected function executeScenario($testMethodName = 'test')
 {
     $result = [];
     $pathToClass = explode('\\', get_called_class());
     $testCaseName = end($pathToClass);
     $config = $this->reader->read('etc');
     if (!empty($config['scenarios'][$testCaseName]['methods'][$testMethodName]['steps'])) {
         $steps = $this->prepareSteps($config['scenarios'][$testCaseName]['methods'][$testMethodName]['steps']);
         /** @var \Mtf\Util\Iterator\Step $stepIterator */
         $stepIterator = $this->objectManager->create('Mtf\\Util\\Iterator\\Step', ['steps' => $steps, 'testCaseName' => $testCaseName, 'testMethodName' => $testMethodName, 'currentVariation' => $this->currentVariation, 'localArguments' => $this->localArguments]);
         $result = $stepIterator->iterate();
     }
     $this->localArguments = array_merge($this->localArguments, $result);
 }
예제 #2
0
 /**
  * @return void
  */
 protected function initialize()
 {
     $scenarioConfig = $this->scenarioConfigReader->read('etc');
     if (empty($scenarioConfig) || empty($scenarioConfig['scenarios'])) {
         $this->testStepCrossModuleMap = [];
         return;
     }
     $testCases = $this->getTestClassesByType(self::CLASS_TYPE_TESTCASE);
     /** @var $testCaseClass \ReflectionClass */
     foreach ($testCases as $testCaseClassName => $testCaseClass) {
         if (!$testCaseClass->isSubclassOf('\\Mtf\\TestCase\\Scenario')) {
             continue;
         }
         $testClassShortName = $testCaseClass->getShortName();
         if (!isset($scenarioConfig['scenarios'][$testClassShortName])) {
             continue;
         }
         $config = $scenarioConfig['scenarios'][$testClassShortName];
         $testStepModules = [];
         $testCaseModule = $config[self::KEY_SCENARIO_MODULE];
         foreach ($config[self::KEY_METHODS] as $testMethod) {
             foreach ($testMethod[self::KEY_STEPS] as $step) {
                 if (!is_array($step)) {
                     continue;
                 }
                 $stepModule = $step[self::KEY_STEP_MODULE];
                 if ($stepModule != $testCaseModule) {
                     $testStepModules[$stepModule] = true;
                 }
             }
         }
         if (!empty($testStepModules)) {
             $this->testStepCrossModuleMap[$testCaseClassName] = $testStepModules;
         }
     }
 }