2

我的测试在我的本地机器上通过了很好的测试,但我正在尝试使用 Travis-CI 并且测试不起作用。我有 ajax 调用,我的 FeatureContext.php 中有以下内容等待它们完成:

/**
 * 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);
}

在 Travis-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
4

1 回答 1

1

我想到了。我忘记将我的资产转储到 travis 配置中。我只是补充说:

- app/console assetic:dump

一切都很好。

于 2013-09-26T06:51:43.973 回答