私は自分のPHPコードをテストするためにphpunitをselenium2で実行しようとしています。phpunit selenium2 repeat test not working
php version : 5.6
laravel version : 5.2
phpunit vesrion : PHPUnit 3.7.28 by Sebastian Bergmann.
セレンサーバーを起動する初期コマンド:
java -Dwebdriver.chrome.driver=/usr/bin/chromedriver -jar ~/Downloads/selenium-server-standalone-3.4.0.jar
にMytest.php
class Mytest extends PHPUnit_Extensions_Selenium2TestCase
{
public function setUp() {
$this->setHost('localhost');
$this->setPort(4444);
$this->setBrowserUrl('http://www.example.com');
$this->setBrowser('chrome'); // firefox
//parent::setUp();
}
public function tearDown() {
$this->stop();
//parent::tearDown();
}
public function testcheckhere(){
$this->url("http://www.google.com");
sleep(5);
}
}
私は、次のコマンドを使用して、コマンドラインを介して上記のコードを実行すると:
vendor/bin/phpunit --filter testcheckhere --verbose --repeat 2 --log-junit textexe.xml tests/selenium/MyTest.php
を
次のエラーが発生します:
PHPUnit 5.7.9 by Sebastian Bergmann and contributors.
Runtime: PHP 5.6.31-2+ubuntu14.04.1+deb.sury.org+1
Configuration: /var/www/html/CRM/phpunit.xml
.E 2/2 (100%)
Time: 9.04 seconds, Memory: 6.25MB
There was 1 error:
1) Mytest::testcheckhere
PHPUnit_Extensions_Selenium2TestCase_WebDriverException: Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'lp-0500', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-43-generic', java.version: '1.8.0_151'
Driver info: driver.version: unknown
/var/www/html/mycode/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/Driver.php:165
/var/www/html/mycode/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/Driver.php:175
/var/www/html/mycode/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/CommandsHolder.php:100
/var/www/html/mycode/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:394
/var/www/html/mycode/tests/selenium/MyTest.php:29
/var/www/html/mycode/tests/selenium/MyTest.php:29
/var/www/html/mycode/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:348
/var/www/html/mycode/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:314
ERRORS!
Tests: 2, Assertions: 0, Errors: 1.
また、テストが実行されている間は、最初のテストでクロムブラウザが1回だけ開き、後で再び開こうとしません。
セレン、サーバーがどこwebdriverをを見つけるために知っていないようです。 –
chromeriverバイナリファイルとseleniumサーバーjarを同じディレクトリに配置する場合、_Dwebdriver.chrome.driver_パラメータを指定する必要はありません。 asterixを使って '$ this-> setBrowser( '* chrome')'を試し、_setUp_メソッド '$ this-> setBrowserUrl'でテストベースURLを設定してください。テストで' $ this-> url( '/' ); 'phpunitは** test **で始まるすべてのメソッドをautomaticallyで呼び出すので、--filter引数は不要です。これらは私の提案ですが、私はこの問題では新しいです。がんばろう。 –