Example #1
0
 public function beforeTest(TestEvent $e)
 {
     if (!$this->isEnabled()) {
         return;
     }
     $this->startCoverageCollection($e->getTest()->getName());
 }
Example #2
0
 public function beforeTest(TestEvent $e)
 {
     $this->logger = new \Monolog\Logger($e->getTest()->getFileName());
     $this->logger->pushHandler($this->logHandler);
     $this->logger->info('------------------------------------');
     $this->logger->info("STARTED: " . ucfirst($e->getTest()->getName(false)));
 }
Example #3
0
 public function beforeTest(TestEvent $e)
 {
     $this->logger = new \Monolog\Logger(Descriptor::getTestFileName($e->getTest()));
     $this->logger->pushHandler($this->logHandler);
     $this->logger->info('------------------------------------');
     $this->logger->info("STARTED: " . ucfirst(Descriptor::getTestAsString($e->getTest())));
 }
Example #4
0
 public function testSuccess(TestEvent $e)
 {
     if ($this->isDetailed($e->getTest())) {
         $this->message('PASSED')->center(' ')->style('ok')->append("\n")->writeln();
         return;
     }
     $this->message('Ok')->writeln();
 }
 public function testSuccess(TestEvent $event)
 {
     $test = $event->getTest();
     if (!$test instanceof TestInterface) {
         return;
     }
     $this->successfulTests[] = Descriptor::getTestSignature($test);
 }
Example #6
0
 public function after(TestEvent $e)
 {
     $seconds_input = $e->getTime();
     // stack overflow: http://stackoverflow.com/questions/16825240/how-to-convert-microtime-to-hhmmssuu
     $seconds = (int) ($milliseconds = (int) ($seconds_input * 1000)) / 1000;
     $time = $seconds % 60 . ($milliseconds === 0 ? '' : '.' . $milliseconds);
     $this->write($e->getTest()->toString());
     $this->writeln(' (' . $time . 's)');
 }
Example #7
0
 public function after(TestEvent $e)
 {
     if (!$e->getTest() instanceof TestCase) {
         return;
     }
     foreach (SuiteManager::$modules as $module) {
         $module->_after($e->getTest());
     }
 }
Example #8
0
 public function after(TestEvent $e)
 {
     if (!$e->getTest() instanceof TestInterface) {
         return;
     }
     foreach ($this->modules as $module) {
         $module->_after($e->getTest());
     }
 }
Example #9
0
 protected function fire($event, TestEvent $eventType)
 {
     $test = $eventType->getTest();
     if ($test instanceof TestCase) {
         foreach ($test->getScenario()->getGroups() as $group) {
             $this->dispatcher->dispatch($event . '.' . $group, $eventType);
         }
     }
     $this->dispatcher->dispatch($event, $eventType);
 }
Example #10
0
 /**
  * @param TestEvent $event
  */
 public function endTest(TestEvent $event)
 {
     $annotations = $event->getTest()->getAnnotations();
     $time = microtime(true) - $this->suiteTime;
     $signature = $event->getTest()->getTestSignature($event->getTest());
     list($class, $method) = explode('::', $signature);
     if (!isset($annotations['class']['ignoreProfiler']) && !isset($annotations['method'][$method]['ignoreProfiler'])) {
         $this->profile[$class][$method] = $time;
     }
 }
 public function afterTest(TestEvent $e)
 {
     $test = new \stdClass();
     $test->name = \Codeception\Test\Descriptor::getTestFileName($e->getTest());
     // stack overflow: http://stackoverflow.com/questions/16825240/how-to-convert-microtime-to-hhmmssuu
     $seconds_input = $e->getTime();
     $seconds = (int) ($milliseconds = (int) ($seconds_input * 1000)) / 1000;
     $time = $seconds % 60;
     $test->time = $time;
     self::$testTimes[] = $test;
 }
 public function beforeTest(\Codeception\Event\TestEvent $e)
 {
     $test = $e->getTest();
     $job = $this->getCorrespondingSaucelabsJob($e);
     try {
         $build = $this->config['build'];
     } catch (\Exception $e) {
         $build = date('d-M-Y');
     }
     $metadata = $this->gatherMetaData($test);
     $this->sauceApi()->updateJob($job['id'], array('name' => $test->getName(), 'build' => $build, 'tags' => $metadata['tags'], 'custom-data' => $metadata['custom-data']));
 }
 public function beforeTest(\Codeception\Event\TestEvent $e)
 {
     $username = $this->config['env_variables'] === true ? getenv('SAUCE_USERNAME') : $this->config['username'];
     $accesskey = $this->config['env_variables'] === true ? getenv('SAUCE_ACCESS_KEY') : $this->config['accesskey'];
     $s = new SauceAPI($username, $accesskey);
     $test = $e->getTest();
     $newestTest = $this->getFirstJob($s);
     try {
         $build = $this->config['build'];
     } catch (\Exception $e) {
         $build = date('d-M-Y');
     }
     $metadata = $this->getMetaData($test);
     $s->updateJob($newestTest['id'], array('name' => $test->getName(), 'build' => $build, 'tags' => $metadata['tags'], 'custom-data' => $metadata['custom-data']));
 }
Example #14
0
 public function testBefore(TestEvent $e)
 {
     if (isset($this->config['connectionIds'])) {
         foreach ((array) $this->config['connectionIds'] as $connectionId) {
             try {
                 (new Mangan($connectionId))->dropDb();
             } catch (ManganException $e) {
                 // Skip if not existing db is about to be dropped
                 if ($e->getCode() !== ExceptionCodeInterface::CouldNotSelect) {
                     throw $e;
                 }
             }
         }
     } else {
         try {
             (new Mangan())->dropDb();
         } catch (ManganException $e) {
             // Skip if not existing db is about to be dropped
             if ($e->getCode() !== ExceptionCodeInterface::CouldNotSelect) {
                 throw $e;
             }
         }
     }
 }
Example #15
0
 protected function writelnFinishedTest(TestEvent $event, Message $result)
 {
     $test = $event->getTest();
     if ($this->isDetailed($test)) {
         return;
     }
     if ($this->output->isInteractive()) {
         $this->output->write("\r");
     }
     $result->append(' ')->write();
     $this->writeCurrentTest($test, false);
     $conditionalFails = "";
     $numFails = count($this->fails);
     if ($numFails == 1) {
         $conditionalFails = "[F]";
     } elseif ($numFails) {
         $conditionalFails = "{$numFails}x[F]";
     }
     $conditionalFails = "<error>{$conditionalFails}</error> ";
     $this->message($conditionalFails)->write();
     $time = $event->getTime();
     if ($time) {
         $seconds = (int) ($milliseconds = (int) ($time * 100)) / 100;
         $time = $seconds % 60 . '.' . $milliseconds;
         $this->message($time)->prepend('(')->append('s)')->style('info')->write();
     }
     $this->output->writeln('');
 }
Example #16
0
 public function beforeTest(TestEvent $e)
 {
     $this->logger = new \Monolog\Logger($e->getTest()->getFileName());
     $this->logger->pushHandler($this->logHandler);
 }
 public function testStart(TestEvent $testEvent)
 {
     $test = $testEvent->getTest();
     $testName = $test->getName();
     $className = get_class($test);
     $event = new TestCaseStartedEvent($this->uuid, $testName);
     if (method_exists($className, $testName)) {
         $annotationManager = new Annotation\AnnotationManager(Annotation\AnnotationProvider::getMethodAnnotations($className, $testName));
         $annotationManager->updateTestCaseEvent($event);
     }
     $this->getLifecycle()->fire($event);
 }
Example #18
0
 public function persist(TestEvent $e)
 {
     if (!$this->webDriverModule or !$this->dir) {
         return;
     }
     $indicatorHtml = '';
     $slideHtml = '';
     foreach ($this->slides as $i => $step) {
         $indicatorHtml .= (new Template($this->indicatorTemplate))->place('step', (int) $i)->place('isActive', (int) $i ? '' : 'class="active"')->produce();
         $slideHtml .= (new Template($this->slidesTemplate))->place('image', $i)->place('caption', $step->getHumanizedArguments())->place('isActive', (int) $i ? '' : 'active')->place('isError', $step->hasFailed() ? 'error' : '')->produce();
     }
     $html = (new Template($this->template))->place('indicators', $indicatorHtml)->place('slides', $slideHtml)->place('feature', ucfirst($e->getTest()->getFeature()))->place('test', TestCase::getTestSignature($e->getTest()))->produce();
     $indexFile = $this->dir . DIRECTORY_SEPARATOR . 'index.html';
     file_put_contents($indexFile, $html);
     $testName = TestCase::getTestSignature($e->getTest()) . ' - ' . ucfirst($e->getTest()->getFeature());
     $this->recordedTests[$testName] = substr($indexFile, strlen(codecept_output_dir()));
 }
Example #19
0
 public function _before(\Codeception\Event\TestEvent $e)
 {
     $e->getTest()->markTestSkipped('WE SKIP TEST');
 }
 public function testFailedPrint(\Codeception\Event\TestEvent $e)
 {
     $name = get_class($e->getTest());
     teamcity_console_logger(MessageTemplate::Warning($name, 'Test Failed Print'));
 }
Example #21
0
 protected function fire($event, TestEvent $eventType)
 {
     $test = $eventType->getTest();
     if ($test instanceof TestInterface) {
         foreach ($test->getMetadata()->getGroups() as $group) {
             $this->dispatcher->dispatch($event . '.' . $group, $eventType);
         }
     }
     $this->dispatcher->dispatch($event, $eventType);
 }
Example #22
0
 public function persist(TestEvent $e)
 {
     if (!$this->webDriverModule or !$this->dir) {
         return;
     }
     $indicatorHtml = '';
     $slideHtml = '';
     foreach ($this->slides as $i => $step) {
         $indicatorHtml .= (new Template($this->indicatorTemplate))->place('step', (int) $i)->place('isActive', (int) $i ? '' : 'class="active"')->produce();
         $slideHtml .= (new Template($this->slidesTemplate))->place('image', $i)->place('caption', $step->getHtml('#3498db'))->place('isActive', (int) $i ? '' : 'active')->place('isError', $step->hasFailed() ? 'error' : '')->produce();
     }
     $html = (new Template($this->template))->place('indicators', $indicatorHtml)->place('slides', $slideHtml)->place('feature', ucfirst($e->getTest()->getFeature()))->place('test', TestCase::getTestSignature($e->getTest()))->produce();
     file_put_contents($this->dir . DIRECTORY_SEPARATOR . 'index.html', $html);
 }
 private function testToName(TestEvent $test)
 {
     return $this->stringToText($test->getTest()->getName(false));
 }
 public function beforeTest(TestEvent $event)
 {
     if (!$this->process->isRunning()) {
         return;
     }
     /** @var \RemoteWebDriver $driver */
     $driver = $this->getModule('WebDriver')->webDriver;
     $this->writeln(["\n", "SauceLabs Connect Info: ", sprintf('SauceOnDemandSessionID=%s job-name=%s', $driver->getSessionID(), $event->getTest()->getName()), ""]);
 }
Example #25
0
 /**
  * @param TestEvent $event
  */
 protected function writeTimeInformation(TestEvent $event)
 {
     $time = $event->getTime();
     if ($time) {
         $this->message(number_format(round($time, 2), 2))->prepend('(')->append('s)')->style('info')->write();
     }
 }