PHPUnit と Selenium 2 を使用して、Web アプリでいくつかの統合テストを行っています。テストが失敗するたびにスクリーンショットを保存したいと思います。これが私がこれまでに持っているものです:
<?php
include 'c:/wamp/www/testarea/selenium/phpunit-selenium/vendor/autoload.php';
class WebTest extends PHPUnit_Extensions_Selenium2TestCase
{
protected function setUp()
{
$this->setBrowser('firefox');
$this->setBrowserUrl('http://www.google.com/');
}
public function testTitle()
{
$this->url('http://www.google.com/');
file_put_contents("c:/wamp/www/testarea/selenium/phpunit-selenium/screenshots/screenshot1.png",$this->currentScreenshot());
$this->assertEquals('NOT GOOGLE', $this->title());
}
}
これは正常に機能し、テストの実行時にスクリーンショットを保存します - ただし、テストが失敗した後にのみスクリーンショットを保存できるようにしたいと考えており、これはすべてのテストで発生するはずです。テストが失敗するたびに関数を自動的に実行するように PHPUnit に指示する方法はありますか?
ありがとう