2014-09-11 6 views
0

터미널에 bin/behat @FootballTeamBundle을 독립 실행 형으로 사용하면 오류 스크린 샷이 찍히고 build/behat/ 폴더에 저장됩니다. bin/phing이면 FeatureContext 파일이 전체적으로 무시 된 것 같아 이상한 스크린 샷이나 내부 메소드 (예 : ** 초 기다림)가 표시되지 않습니다. 누구나 해결책을 알고 있습니까?bin/behat @FootballTeamBundle은 괜찮지 만 bin/phing은 FeatureContext를 실행하지 않습니다.

또한 내 build.xml에서 행을 bin/behat -f progress --format html --out ${dir-report}/behat.html에서 bin/behat @FootballTeamBundle으로 업데이트했지만 아무 것도 변경되지 않았습니다.

미리 감사드립니다.

/var/www/html/local/sport/behat.yml

default: 
    context: 
     class: FeatureContext 
     parameters: 
      screen_shots_path: 'build/behat/' 
    extensions: 
     Behat\Symfony2Extension\Extension: 
      mink_driver: true 
      kernel: 
       env: test 
       debug: true 
     Behat\MinkExtension\Extension: 
      base_url: 'http://localhost/local/sport/web/app_test.php/' 
      files_path: 'dummy/' 
      browser_name: chrome 
      goutte: ~ 
      selenium2: ~ 
    paths: 
     features: src/Football/TeamBundle/Features 
     bootstrap: %behat.paths.features%/Context 

의/var/www/html/지역/스포츠/SRC/축구/TeamBundle/기능/컨텍스트/FeatureContext .PHP

<?php 

namespace Football\TeamBundle\Features\Context; 

use Behat\MinkExtension\Context\MinkContext; 
use Behat\Mink\Exception\UnsupportedDriverActionException; 
use Behat\Mink\Driver\Selenium2Driver; 

class FeatureContext extends MinkContext 
{ 
    /** 
    * Where the failure images will be saved. 
    * 
    * @var string 
    */ 
    protected $screenShotsPath; 

    /** 
    * Comes from behat.yml file. 
    * 
    * @param $parameters 
    */ 
    public function __construct($parameters) 
    { 
     $this->screenShotsPath = $parameters['screen_shots_path']; 
    } 

    /** 
    * Take screen-shot when step fails. 
    * Works only with Selenium2Driver. 
    * 
    * @AfterStep 
    * @param $event 
    * @throws \Behat\Mink\Exception\UnsupportedDriverActionException 
    */ 
    public function takeScreenshotAfterFailedStep($event) 
    { 
     if (4 === $event->getResult()) { 
      $driver = $this->getSession()->getDriver(); 

      if (! ($driver instanceof Selenium2Driver)) { 
       throw new UnsupportedDriverActionException(
        'Taking screen-shots is not supported by %s, use Selenium2Driver instead.', 
        $driver 
       ); 

       return; 
      } 

      if (! is_dir($this->screenShotsPath)) { 
       mkdir($this->screenShotsPath, 0777, true); 
      } 

      $filename = sprintf(
       '%s_%s_%s.%s', 
       $this->getMinkParameter('browser_name'), 
       date('Y-m-d') . '_' . date('H:i:s'), 
       uniqid('', true), 
       'png' 
      ); 

      file_put_contents($this->screenShotsPath . '/' . $filename, $driver->getScreenshot()); 
     } 
    } 

    /** 
    * @Then /^I wait for "([^"]*)" seconds$/ 
    * 
    * @param $seconds 
    */ 
    public function iWaitForGivenSeconds($seconds) 
    { 
     $this->getSession()->wait($seconds*1000); 
    } 
} 

/var/www/html/local/sport/build.xml

<!-- GLOBAL VARIABLES --> 
<property name="dir-source" value="${project.basedir}/src" /> 
<property name="dir-report" value="${project.basedir}/build/phing" /> 
<!-- END --> 

<!-- AVAILABLE CLI COMMANDS --> 
<target name="build" 
     description="Runs everything in order ..." 
     depends="cache-clear, cache-warm, load-fixtures, codesniffer-psr2, behat-bdd" /> 
<!-- END --> 

<!-- FILESET --> 
<fileset id="sourcecode" dir="${dir-source}"> 
    <include name="**/*.php" /> 
</fileset> 
<!-- END --> 

............. OTHER TESTS ARE HERE, JUST REMOVED TO KEEP IT CLEAN 

<!-- BEHAT - BDD --> 
<target name="behat-bdd"> 
    <echo msg="Running Behat tests ..." /> 
    <exec logoutput="true" checkreturn="true" 
      command="bin/behat -f progress --format html --out ${dir-report}/behat.html" 
      dir="./" /> 
</target> 
<!-- END --> 

+0

의 dir을 $ {dir-source}와 같이 설정하면 안됩니까? –

답변

2

나는 결코 phing이나 심포니 팬 처리하지 않습니다. 바라기를 이것은 순전히 설정 문제입니다. %behat.paths.base%을 사용하여 경로와 관련성을 높이십시오. 당신이 behat.yml 앉는 곳

default: 
    context: 
     class: Football\TeamBundle\Features\Context\FeatureContext 
     parameters: 
      screen_shots_path: %behat.paths.base%/build/behat/ 
    extensions: 
     Behat\Symfony2Extension\Extension: 
      mink_driver: true 
      kernel: 
       env: test 
       debug: true 
     Behat\MinkExtension\Extension: 
      base_url: 'http://localhost/local/sport/web/app_test.php/' 
      files_path: %behat.paths.base%/dummy/ 
      browser_name: chrome 
      goutte: ~ 
      selenium2: ~ 
    paths: 
     features: %behat.paths.base%/src 
     bootstrap: %behat.paths.features%/Context 

%behat.paths.base%이다) 또한 네임 스페이스를 사용합니다. 그래서 그것과 관련된 올바른 경로를 설정하여 config를 업데이트하십시오.

+0

당신의 조언대로 편집되었지만 여전히 phing의 스크린 샷이 없습니다. – BentCoder

+0

오 오케이. 뭔가 놓쳤다. 지금은 괜찮아. 다시 한번 감사드립니다. – BentCoder

+0

나는 behat, phing 및 Symfony2에 대한 새로운 기술이므로 계속 진행 중입니다. Phing은 아주 좋은 도구입니다. 나 이거 굉장히 좋아! – BentCoder