Symfony2扩展名-Behat Mink [英] Symfony2 Extension - Behat Mink

查看:40
本文介绍了Symfony2扩展名-Behat Mink的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从此处
为Behat Mink安装了Symfony2扩展程序 当我运行测试时,会发生错误

I installed a Symfony2 extension for Behat Mink from here
When I run test, an error occurs

[ReflectionException]类AppKernel不存在.

[ReflectionException] Class AppKernel does not exist.

我在做什么错了?

behat.yml

default:
extensions:
    Behat\MinkExtension\Extension:
        base_url: http://localhost/behat
        goutte: ~
        selenium2: ~
    Behat\Symfony2Extension\Extension: ~

推荐答案

首先运行以下命令来安装依赖项:

First run these commands to install the dependencies:

composer require behat/behat
composer require behat/symfony2-extension
composer require behat/mink
composer require behat/mink-browserkit-driver
composer require behat/mink-extension
composer require behat/mink-goutte-driver
composer require behat/mink-selenium2-driver
composer require emuse/behat-html-formatter
composer require coduo/php-matcher

现在说出要作为localhost.behat托管的symfony应用,然后将vhost配置添加到httpd_vhost.conf:

Now say your symfony applcation you want to host as localhost.behat, then add the vhost configuration to httpd_vhost.conf:

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/behat/web"
    ServerName lochost.behat
    DirectoryIndex app_dev.php
    <Directory "C:/xampp/htdocs/behat/web">
        Order deny,allow
        Allow from all
    </Directory>    
</VirtualHost>

现在,您的behat.yml文件应该位于app/config/behat.yml中,且具有belo内容:

Now your behat.yml file should be at app/config/behat.yml with belo content :

default:
    formatters:
        html:
            output_path: web/behat
    extensions:
        Behat\Symfony2Extension: ~
        # Irs\BehatPopupExtension\Extension: ~
        Behat\MinkExtension:
            base_url: http://lochost.behat/app_dev.php/
            javascript_session: selenium2
            sessions:
                symfony2:
                    symfony2: ~
                selenium2:
                    selenium2:
                        browser: chrome
        emuse\BehatHTMLFormatter\BehatHTMLFormatterExtension:
            name: html
            renderer: Twig,Behat2
            file_name: index
            print_args: true
            print_outp: true
            loop_break: true
    suites:
        api:
            type: symfony_bundle
            bundle: NameSpaceYourBundle
            #mink_session: symfony2
            mink_session: selenium2
            contexts:
                - NameSpace\YourBundle\Features\Context\FeatureContext:
                    baseUrl: http://lochost.behat/app_dev.php/
                    screenCapturePath: web/behat

# Add "-p firefox" parameter to behat command to run tests with Firefox browser
firefox:
    extensions:
        Behat\MinkExtension\Extension:
            browser_name: firefox

# Add "-p chrome" parameter to behat command to run tests with Chrome browser
chrome:
    extensions:
        #Behat\MinkExtension\Extension:
        Behat\MinkExtension:
            browser_name: chrome

# Add "-p safari" parameter to behat command to run tests with Safari browser
safari:
    extensions:
        Behat\MinkExtension\Extension:
            browser_name: safari

所有操作,现在将您的功能和上下文文件添加到名称空间:NameSpace \ YourBundle \ Features \ Context \ FeatureContext

All you go, now add your feature and context file at namespace : NameSpace\YourBundle\Features\Context\FeatureContext

并从命令提示符/git bash(首选)中运行以下命令:

and run the below commands from command prompt/git bash(preferrable):

bin/behat -v --suite=api @NameSpaceYourBundle/your.feature --config=app/config/behat.yml -f pretty

或者如果要将输出另存为html,则保存在web/behat目录中:

or if you want to save the output as html at web/behat directory then:

bin/behat -v --suite=api @NameSpaceYourBundle/your.feature --config=app/config/behat.yml

让我知道它是否有效

注意: 我不确定您是在运行selenium服务器还是独立服务器,因此添加了运行selenium独立服务器的步骤:

Note: I am not sure if you are running selenium server or standalone server, hence adding the step to run selenium standalone server:

下载

Download selenium and chromedriver and place the selenium server .exe and chromedriver.exe in same folder check with "java -version" and it should not be < 1.6.x you may need to download compatible selenium server and chrome driver open command prompt and run the below commands:

cd C:\<folder contains selenium server .exe and chromedriver.exe>
java -Dwebdriver.chrome.driver="chromedriver.exe" -jar selenium-server-standalone-x.xx.0.jar

这篇关于Symfony2扩展名-Behat Mink的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆