public function testCreateSnapshotOnFail() { $module = Stub::construct(get_class($this->module), [make_container()], ['_savePageSource' => Stub::once(function ($filename) { $this->assertEquals(codecept_log_dir('Codeception.Module.UniversalFramework.looks.like..test.fail.html'), $filename); })]); $module->amOnPage('/'); $cest = new \Codeception\Test\Cest($this->module, 'looks:like::test', 'demo1Cest.php'); $module->_failed($cest, new PHPUnit_Framework_AssertionFailedError()); }
/** * Takes a screenshot of the current window and saves it to `tests/_output/debug`. * * ``` php * <?php * $I->amOnPage('/user/edit'); * $I->makeScreenshot('edit_page'); * // saved to: tests/_output/debug/edit_page.png * ?> * ``` * * @param $name */ public function makeScreenshot($name) { $debugDir = codecept_log_dir() . 'debug'; if (!is_dir($debugDir)) { mkdir($debugDir, 0777); } $screenName = $debugDir . DIRECTORY_SEPARATOR . $name . '.png'; $this->_saveScreenshot($screenName); $this->debug("Screenshot saved to {$screenName}"); }
public function testCreateTestScreenshotOnFail() { $test = Stub::make('\\Codeception\\TestCase\\Test', ['getName' => 'testLogin']); $fakeWd = Stub::make(self::WEBDRIVER_CLASS, ['takeScreenshot' => Stub::once(function ($filename) use($test) { PHPUnit_Framework_Assert::assertEquals(codecept_log_dir(get_class($test) . '.testLogin.fail.png'), $filename); }), 'getPageSource' => Stub::once(function () { }), 'manage' => Stub::make('\\Facebook\\WebDriver\\WebDriverOptions', ['getAvailableLogTypes' => Stub::atLeastOnce(function () { return []; })])]); $module = Stub::make(self::MODULE_CLASS, ['webDriver' => $fakeWd]); $module->_failed($test, new PHPUnit_Framework_AssertionFailedError()); }
public function testCreateTestScreenshotOnFail() { $test = Stub::make('\\Codeception\\TestCase\\Test', ['getName' => 'testLogin']); $fakeWd = Stub::make('\\RemoteWebDriver', ['takeScreenshot' => Stub::once(function ($filename) use($test) { PHPUnit_Framework_Assert::assertEquals(codecept_log_dir(get_class($test) . '.testLogin.fail.png'), $filename); }), 'getPageSource' => Stub::once(function () { })]); $this->module->webDriver = $fakeWd; $this->module->_failed($test, new PHPUnit_Framework_AssertionFailedError()); }
public function testCreateTestScreenshotOnFail() { $test = Stub::make('\\Codeception\\TestCase\\Test', ['getName' => 'testLogin']); $wd = Stub::make('\\Codeception\\Module\\WebDriver', ['_saveScreenshot' => Stub::once(function ($actual) use($test) { PHPUnit_Framework_Assert::assertEquals(codecept_log_dir(get_class($test) . '.testLogin.fail.png'), $actual); })]); $wd->_failed($test, new PHPUnit_Framework_AssertionFailedError()); }