示例#1
0
 public function _failed(TestCase $test, $fail)
 {
     if (!$this->client || !$this->client->getInternalResponse()) {
         return;
     }
     $this->_savePageSource(codecept_output_dir() . str_replace(['::', '\\', '/'], ['.', '.', '.'], TestCase::getTestSignature($test)) . '.fail.html');
 }
示例#2
0
 public function _failed(TestCase $test, $fail)
 {
     if (!$this->client || !$this->client->getInternalResponse()) {
         return;
     }
     $filename = str_replace(['::', '\\', '/'], ['.', '', ''], TestCase::getTestSignature($test)) . '.fail.html';
     file_put_contents(codecept_output_dir($filename), $this->client->getInternalResponse()->getContent());
 }
示例#3
0
 /**
  * @group core
  */
 public function testCeptNamings()
 {
     $cept = new \Codeception\TestCase\Cept();
     $cept->configName('LoginCept.php')->config('testFile', 'tests/acceptance/LoginCept.php');
     $this->assertEquals('tests/acceptance/LoginCept.php', \Codeception\TestCase::getTestFileName($cept));
     $this->assertEquals('tests/acceptance/LoginCept.php', \Codeception\TestCase::getTestFullName($cept));
     $this->assertEquals('LoginCept', \Codeception\TestCase::getTestSignature($cept));
 }
示例#4
0
 /**
  * @group core
  */
 public function testCestNamings()
 {
     $cept = new \Codeception\TestCase\Cest();
     $klass = new stdClass();
     $cept->config('testClassInstance', $klass)->config('testMethod', 'user')->config('testFile', 'tests/acceptance/LoginCest.php');
     $this->assertEquals('tests/acceptance/LoginCest.php:user', \Codeception\TestCase::getTestFullName($cept));
     $this->assertEquals('tests/acceptance/LoginCest.php', \Codeception\TestCase::getTestFileName($cept));
     $this->assertEquals('stdClass::user', \Codeception\TestCase::getTestSignature($cept));
 }
示例#5
0
 protected function getTestNames($tests)
 {
     $testNames = [];
     foreach ($tests as $test) {
         if ($test instanceof \PHPUnit_Framework_TestCase) {
             $testNames[] = \Codeception\TestCase::getTestSignature($test);
         }
     }
     return $testNames;
 }
示例#6
0
 protected function assertContainsTestName($name, $tests)
 {
     foreach ($tests as $test) {
         if ($test instanceof \PHPUnit_Framework_TestCase) {
             $testName = \Codeception\TestCase::getTestSignature($test);
             if ($testName == $name) {
                 return;
             }
             codecept_debug($testName);
         }
     }
     $this->fail("{$name} not found in tests");
 }
示例#7
0
 public function _failed(\Codeception\TestCase $test, $fail)
 {
     $filename = str_replace(['::', '\\', '/'], ['.', '', ''], \Codeception\TestCase::getTestSignature($test)) . '.fail.png';
     $this->_saveScreenshot(codecept_output_dir($filename));
     $this->debug("Screenshot was saved into '_output' dir");
 }
示例#8
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()));
 }
示例#9
0
 public function _failed(TestCase $test, $fail)
 {
     $this->debugWebDriverLogs();
     $filename = str_replace(['::', '\\', '/'], ['.', '', ''], TestCase::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");
 }
示例#10
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);
 }
示例#11
0
 public function _failed(\Codeception\TestCase $test, $fail)
 {
     $filename = str_replace(['::', '\\', '/'], ['.', '', ''], \Codeception\TestCase::getTestSignature($test)) . '.fail';
     $this->_saveScreenshot(codecept_output_dir() . $filename . '.png');
     file_put_contents(codecept_output_dir() . $filename . '.html', $this->webDriver->getPageSource());
     $this->debug("Screenshot and HTML snapshot were saved into '_output' dir");
 }