public function _failed(TestInterface $test, $fail) { if (!$this->client || !$this->client->getInternalResponse()) { return; } $this->_savePageSource(codecept_output_dir() . str_replace(['::', '\\', '/'], ['.', '.', '.'], Descriptor::getTestSignature($test)) . '.fail.html'); }
/** * @group core */ public function testCeptNamings() { $cept = new \Codeception\Test\Cept('Login', 'tests/acceptance/LoginCept.php'); $this->assertEquals('tests/acceptance/LoginCept.php', \Codeception\Test\Descriptor::getTestFileName($cept)); $this->assertEquals('tests/acceptance/LoginCept.php', \Codeception\Test\Descriptor::getTestFullName($cept)); $this->assertEquals('LoginCept', \Codeception\Test\Descriptor::getTestSignature($cept)); }
protected function getTestNames($tests) { $testNames = []; foreach ($tests as $test) { $testNames[] = \Codeception\Test\Descriptor::getTestSignature($test); } return $testNames; }
public function codeCoverageStart() { $codeCoverage = $this->getTestResultObject()->getCodeCoverage(); if (!$codeCoverage) { return; } $codeCoverage->start(Descriptor::getTestSignature($this)); }
public function testSuccess(TestEvent $event) { $test = $event->getTest(); if (!$test instanceof TestInterface) { return; } $this->successfulTests[] = Descriptor::getTestSignature($test); }
/** * @group core */ public function testCestNamings() { $klass = new stdClass(); $cest = new \Codeception\Test\Cest($klass, 'user', 'tests/acceptance/LoginCest.php'); $this->assertEquals('tests/acceptance/LoginCest.php:user', \Codeception\Test\Descriptor::getTestFullName($cest)); $this->assertEquals('tests/acceptance/LoginCest.php', \Codeception\Test\Descriptor::getTestFileName($cest)); $this->assertEquals('stdClass:user', \Codeception\Test\Descriptor::getTestSignature($cest)); }
public function _failed(TestInterface $test, $fail) { if (!$this->client || !$this->client->getInternalResponse()) { return; } $filename = preg_replace('~\\W~', '.', Descriptor::getTestSignature($test)); $filename = mb_strcut($filename, 0, 244, 'utf-8') . '.fail.html'; $this->_savePageSource(codecept_output_dir() . $filename); }
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(Descriptor::getTestSignature($e->getTest())); $this->writeln(' (' . $time . 's)'); }
protected function findMatchedTest($testSignature) { foreach ($this->tests as $test) { $signature = Descriptor::getTestSignature($test); if ($signature === $testSignature) { return $test; } } if ($test instanceof TestInterface) { $test->getMetadata()->setSkip("Dependent test for {$testSignature} not found"); } }
public function accept() { $test = $this->getInnerIterator()->current(); if ($test instanceof \PHPUnit_Framework_TestSuite) { return true; } $name = Descriptor::getTestSignature($test); $accepted = preg_match($this->filter, $name, $matches); if ($accepted && isset($this->filterMax)) { $set = end($matches); $accepted = $set >= $this->filterMin && $set <= $this->filterMax; } return $accepted; }
public function startTest(TestEvent $e) { $this->fails = []; $test = $e->getTest(); $this->printedTest = $test; $this->message = null; if (!$this->output->isInteractive() and !$this->isDetailed($test)) { return; } $this->writeCurrentTest($test); if ($this->isDetailed($test)) { $this->output->writeln(''); $this->message(Descriptor::getTestSignature($test))->style('info')->prepend('Signature: ')->writeln(); $this->message(codecept_relative_path(Descriptor::getTestFullName($test)))->style('info')->prepend('Test: ')->writeln(); if ($this->steps) { $this->message('Scenario --')->style('comment')->writeln(); $this->output->waitForDebugOutput = false; } } }
public function _failed(TestInterface $test, $fail) { $this->debugWebDriverLogs(); $filename = str_replace([':', '\\', '/'], ['.', '', ''], Descriptor::getTestSignature($test)) . '.fail'; $this->_saveScreenshot(codecept_output_dir() . $filename . '.png'); $this->_savePageSource(codecept_output_dir() . $filename . '.html'); $this->debug("Screenshot and page source were saved into '_output' dir"); }
<!DOCTYPE html> <html> <head> <title>VisualCeption Report</title> </head> <body> <img src="http://www.thewebhatesme.com/wp-content/uploads/visualception.png" /> <?php foreach ($failedTests as $failedTest) { ?> <div class="failedTest"> <h2><?php $failedMetadata = $failedTest->getFailedTest()->getMetadata(); echo \Codeception\Test\Descriptor::getTestSignature($failedTest->getFailedTest()) . " (" . $failedMetadata->getCurrent('env') . ")"; ?> </h2> <div class="deviationimage"> Deviation Image <br /> <img src='data:image/png;base64,<?php echo base64_encode(file_get_contents($failedTest->getDeviationImage())); ?> ' /> </div> <div class="expectedimage"> Expected Image <br /> <img src='data:image/png;base64,<?php echo base64_encode(file_get_contents($failedTest->getExpectedImage())); ?>
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', Descriptor::getTestSignature($e->getTest()))->place('carousel_class', $this->config['animate_slides'] ? ' slide' : '')->produce(); $indexFile = $this->dir . DIRECTORY_SEPARATOR . 'index.html'; file_put_contents($indexFile, $html); $testName = Descriptor::getTestSignature($e->getTest()) . ' - ' . ucfirst($e->getTest()->getFeature()); $this->recordedTests[$testName] = substr($indexFile, strlen(codecept_output_dir())); }
/** * A failure occurred. * * @param \PHPUnit_Framework_Test $test * @param \PHPUnit_Framework_AssertionFailedError $e * @param float $time */ public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time) { $this->failures[Descriptor::getTestSignature($test)] = $this->cleanMessage($e); parent::addFailure($test, $e, $time); }
public function _failed(TestInterface $test, $fail) { $this->debugWebDriverLogs(); $filename = preg_replace('~\\W~', '.', Descriptor::getTestSignature($test)); $outputDir = codecept_output_dir(); $this->_saveScreenshot($outputDir . mb_strcut($filename, 0, 245, 'utf-8') . '.fail.png'); $this->_savePageSource($outputDir . mb_strcut($filename, 0, 244, 'utf-8') . '.fail.html'); $this->debug("Screenshot and page source were saved into '{$outputDir}' dir"); }