/**
  * {@inheritdoc}
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $result = null;
     $maxProcessesAmount = max(1, $input->getOption(self::OPTION_PARALLEL_PROCESS));
     $locator = $input->getArgument('paths');
     if ($maxProcessesAmount > 1) {
         $this->outputPrinter->init($output);
         $this->processFactory->init($this->inputDefinition, $input);
         $this->featureRunner->setMaxParallelProcess($maxProcessesAmount);
         $result = 0;
         foreach ($this->featureExtractor->extract($locator) as $featureNode) {
             $result = max($result, $this->featureRunner->run($featureNode));
         }
     }
     return $result;
 }
 /**
  * @param array $scenarioGroups
  *
  * @dataProvider providerRun
  */
 public function testRun(array $scenarioGroups)
 {
     $eventDispatcher = $this->getMock(EventDispatcherInterface::class);
     $scenarioInfoExtractor = $this->getMock(ScenarioInfoExtractor::class, ['extract']);
     $scenarioInfoExtractor->expects($this->once())->method('extract')->willReturn($scenarioGroups);
     $scenarioProcessFactory = $this->getMock(ScenarioProcessFactory::class, ['make']);
     $index = 0;
     $processGroups = [];
     foreach ($scenarioGroups as $groupId => $scenarios) {
         $processGroups[$groupId] = [];
         foreach ($scenarios as $scenarioInfo) {
             $process = $this->getMock(ScenarioProcess::class, null, [$scenarioInfo, '']);
             $processGroups[$groupId][] = $process;
             $scenarioProcessFactory->expects($this->at($index))->method('make')->with($scenarioInfo)->willReturn($process);
             $index++;
         }
     }
     $scenarioProcessFactory->expects($this->exactly($index))->method('make');
     $parallelProcessRunner = $this->getMock(ParallelProcessRunner::class, ['reset', 'add', 'run']);
     $parallelProcessRunner->expects($this->exactly(count($processGroups)))->method('reset')->willReturn($parallelProcessRunner);
     foreach ($processGroups as $index => $processes) {
         // count index with methods amount correction
         $parallelProcessRunner->expects($this->at($index * 3 + 1))->method('add')->with($processes)->willReturn($parallelProcessRunner);
     }
     $parallelProcessRunner->expects($this->exactly(count($processGroups)))->method('add');
     $parallelProcessRunner->expects($this->exactly(count($processGroups)))->method('run')->willReturn($parallelProcessRunner);
     $featureNode = $this->getMock(FeatureNode::class, [], [], '', false);
     /** @var EventDispatcherInterface $eventDispatcher */
     /** @var ScenarioInfoExtractor $scenarioInfoExtractor */
     /** @var ScenarioProcessFactory $scenarioProcessFactory */
     /** @var ParallelProcessRunner $parallelProcessRunner */
     /** @var FeatureNode $featureNode */
     $featureRunner = new FeatureRunner($eventDispatcher, $scenarioInfoExtractor, $scenarioProcessFactory, $parallelProcessRunner);
     $featureRunner->run($featureNode);
 }