2014-11-26 3 views
1

나는 laravel 4에 대한 수용 테스트를 코드 작성 및 셀레늄 모듈로 작성하려고합니다.변경 env 수락 테스트시 laravel 앱 (코드 테셀 션 및 셀렌 포함)

두 가지 문제점이 있습니다.

  • 첫 번째는 내 앱이 농가 방랑의 VM의 를 실행하고, 셀레늄 서버가 호스트 시스템에서 실행되고 있다는 점이다. 그렇다면 VM에서 셀렌 서버를 실행하고 브라우저에서 호스트 시스템을 호출하는 쉬운 방법이 있습니까?

  • 두 번째 문제는 laravel 앱의 환경이 테스트로 설정되지 않았기 때문에 실제 실제 데이터베이스를 테스트 할 때 문제가되는 것입니다. 분명히 나는 ​​그것이 테스트 데이터베이스를 사용하고 각 테스트 후에 그것을 다시 가지고 싶습니다.

codeception.yaml

actor: Tester 
paths: 
    tests: app/tests 
    log: app/tests/_output 
    data: app/tests/_data 
    helpers: app/tests/_support 
settings: 
    bootstrap: _bootstrap.php 
    colors: true 
    memory_limit: 1024M 
    suite_class: \PHPUnit_Framework_TestSuite 
modules: 
    config: 
     Db: 
      dsn: 'sqlite:app/tests/_data/testdb.sqlite' 
      user: '' 
      password: '' 
      dump: app/tests/_data/dump.sql 

acceptance.yaml

class_name: AcceptanceTester 
modules: 
    enabled: [WebDriver,AcceptanceHelper] 
    config: 
     WebDriver: 
      url: 'http://app.dev' 
      browser: firefox 
      window_size: 1920x1024 
      wait: 10 

답변

0

는 VM에서 수용 테스트를 실행하는 쉬운 방법은 ghostdriver 모드에서 팬텀 JS를 사용하는 것입니다. 이 여기에 튜토리얼입니다 : 당신은 여전히 ​​스크린 샷과 테스트가 실패 렌더링 된 HTML을 볼 수 있습니다

https://gist.github.com/antonioribeiro/96ce9675e5660c317bcc

, 그래서 당신이 브라우저를 볼 수없는 큰 문제가되지 않습니다.

두 번째 질문에 대해서는 별도의 테스트 설치를 자체 데이터베이스와 함께 유지하는 것을 선호합니다. 이렇게하면 dev에서 변경하면 테스트 결과가 변경되지 않고 더 나은 결과를 얻을 수 있습니다.

동일한 설치를 사용하려는 경우 .env 파일로 설정을 전환하는 작업을 자동화 할 수 있습니다.

'host'  => $_ENV['DB_HOST'], 
'database' => $_ENV['DB_NAME'], 
'username' => $_ENV['DB_USERNAME'], 
'password' => $_ENV['DB_PASSWORD'], 

을하고 .env.php과 같을 것이다 :

http://laravel.com/docs/4.2/configuration#protecting-sensitive-configuration

당신의 설정은 다음과 같이 보일 것이다 당신에게 로보 같은 작업 러너를 사용할 수있는 것보다

return array('DB_HOST' => 'hostname', 'DB_NAME' => '' ..etc 

.env 파일을 자동으로 업데이트하고 코드 테스팅 테스트를 실행합니다.

http://robo.li/

$this->replaceInFile('.env.php') 
    ->from('production_db_name') 
    ->to('test_db_name') 
    ->run(); 

$this->taskCodecept()->suite('acceptance')->run(); 

.env의 파일은 Laravel 5 변화하고 있지만,이 워크 플로는 여전히 최소한의 수정으로 작동합니다.

http://mattstauffer.co/blog/laravel-5.0-environment-detection-and-environment-variables