0

PHP 코드를 테스트하기 위해 selenium2로 phpunit을 실행하려고합니다.phpunit selenium2 반복 테스트가 작동하지 않습니다.

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. 

또한 테스트가 실행되는 동안 크롬 브라우저는 첫 번째 테스트 중에 한 번만 열리고 나중에 다시 열려고 시도하지 않습니다.

+0

그 셀레늄 서버가 webdriver를 어디서 찾을 수 있는지 모르는 것 같다. –

+0

chromeriver binary file과 selenium server jar를 같은 디렉토리에두면 _Dwebdriver.chrome.driver_ parameter를 지정할 필요가 없습니다. asterix와 함께'$ this-> setBrowser ('* chrome')'을 시도하고 _setUp_ 메소드'$ this-> setBrowserUrl'에서 테스트베이스 URL을 설정하면 테스트에서'$ this-> url ('/');'phpunit은 ** test **로 시작하는 모든 메소드를 자동으로 호출하므로 --filter 인수는 필요 없습니다. 이것들은 제 제안이지만, 저는이 문제에있어서 새로운 것입니다. 행운을 빕니다. –

답변

-2

php 버전 : 5.6 laravel 버전 : 5.2 phpunit vesrion : PHPUnit 3.7.28 by Sebastian Bergmann.

업데이트와 같은 XAMPP 폴더에 phpunit을 버전 : ": \ XAMPP의 \ PHP는 C"에 https://phpunit.de/index.html 2 복사 "phpunit.phar"

1은 여기 phpunit을의 마지막 버전을 다운로드합니다. 3- 파일에서 : "phpunit.bat.bat", "% PHPBIN %" "C : \ xampp \ php \ phpunit"% *을 "% PHPBIN %" "C : \ xampp \ php \ phpunit.phar "% *

PHP 버전과 phpunit 버전이 서로 호환되면 버전 호환성 문제가 있습니다. 그러면 응용 프로그램이 문제없이 실행됩니다. 그것은 당신의 PHP 버전과 호환 될 것이기 때문에 phpunit.phar 파일 버전 5.7.26을 다운로드

또한 함수 제거 :) (

공공 기능 형 분석() { $ this-> 정지 ;

//parent::tearDown(); 

}

+0

이것은 셀레늄 테스트와 어떤 관련이 있습니까? –

+0

PHPUnit-Selenium 라이브러리를 사용하고 있습니다. 오류를 해결하려면 모든 버전 호환성을 설정해야합니다. – Sufyan

관련 문제