2013-09-25 147 views
2

我有我的本地機器正常傳遞的測試,但我試圖使用Travis-CI,測試不起作用。我有Ajax調用,並在我的FeatureContext.php我有以下等待它們完成:Travis-CI上的Ajax測試

/** 
* Wait either $duration milliseconds or until jQuery: is undefined or has no active ajax calls AND has no active animations 
* 
* @param int $duration 
*/ 
protected function jqueryWait($duration = 1000) 
{ 
    $this->getSession()->wait($duration, '(typeof jQuery === \'undefined\' || (0 === jQuery.active && 0 === jQuery(\':animated\').length))'); 
} 

/** 
* @When /^I wait for the response$/ 
*/ 
public function iWaitForTheResponse() 
{ 
    $this->jqueryWait(20000); 
} 

它不特拉維斯CI測試過程中等待。這裏是我的behat.yml和.travis.yml文件:

behat.yml

default: 
    paths: 
     features: features 
     bootstrap: features/bootstrap 
    context: 
#  class: FeatureContext 
     class: BConway\TrackerBundle\Features\Context\FeatureContext 
    formatter: 
     name: pretty,html 
     parameters: 
      decorated:    true 
      verbose:    true 
      time:     true 
      language:    en 
      output_path:   null,test_report.html 
      multiline_arguments: true 
    extensions: 
     Behat\Symfony2Extension\Extension: 
      mink_driver: true 
      kernel: 
       env: test 
       debug: true 
     Behat\MinkExtension\Extension: 
      base_url: 'http://kimweighttracker.dev/app_test.php/' 
      default_session: goutte 
      zombie: ~ 
      goutte: ~ 
      selenium2: 
       capabilities: { "browser": "firefox" } 

annotations: 
    paths: 
     features: features/annotations 

closures: 
    paths: 
     features: features/closures 

user: 
    filters: 
     tags: "@user" 

goal: 
    filters: 
     tags: "@goal" 

entry: 
    filters: 
     tags: "@entry" 

behavior: 
    filters: 
     tags: "@behavior" 

.travis.yml

language: php 

php: 
    - 5.4 

before_script: 
    # Install php packages 
    - sudo apt-get update > /dev/null 
    - sudo apt-get install -y --force-yes apache2 libapache2-mod-php5 php5-curl php5-mysql php5-intl 

    # Create VirtualHost 
    - sudo sed -i -e "s,/var/www,$(pwd)/web,g" /etc/apache2/sites-available/default 
    - sudo sed -i -e "/DocumentRoot/i\ServerName kimweighttracker.dev" /etc/apache2/sites-available/default 
    - echo "127.0.0.1 kimweighttracker.dev" | sudo tee -a /etc/hosts 
    - sudo /etc/init.d/apache2 restart 

    # Copy skeleton parameters file 
    - cp app/config/parameters.yml.dist app/config/parameters.yml 

    # Update composer 
    - composer self-update 
    - composer install --dev --prefer-dist 

    - app/console -n doctrine:database:create -e=test > /dev/null 
    - app/console -n doctrine:migrations:migrate -e=test > /dev/null 
    - chmod -R 777 app/cache app/logs 
    - app/console --env=test cache:warmup 
    - chmod -R 777 app/cache app/logs 

    # Setup selenium 
    - "sh -e /etc/init.d/xvfb start" 
    - "export DISPLAY=:99.0" 
    - "wget http://selenium.googlecode.com/files/selenium-server-standalone-2.31.0.jar" 
    - "java -jar selenium-server-standalone-2.31.0.jar > /dev/null &" 
    - sleep 5 


script: bin/behat 

回答

1

我想通了。我忘了將我的資產轉儲到Travis配置中。我簡單地補充說:

- app/console assetic:dump 

和一切工作很好。