繁体   English   中英

如何在Behat中启用Mink扩展

[英]How to enable Mink extension in Behat

我试图使用Mink进行简单的behat测试,但是当我运行behat命令时出现错误:“未在Mink上下文类上设置Mink实例。是否启用了Mink扩展?(RuntimeException)”

这是我的behat.yml:

default:
    extensions:
        Behat\MinkExtension:
            base_url: "https://en.wikipedia.org"
            sessions: 
                default:
                    selenium2:
                        wd_host: http://localhost:4444/wd/hub

这是我的功能:

Feature: search wikipedia
    In order to learn about BDD
    As a passionate developers
    I need to be able to search a general internet site

Scenario:
    Given I am in wikipedia
    When I search for "Behaviour driven development"
    Then the first heading should be "Behaviour-driven-development"

这是我的FeatureContext.php:

<?php

use Behat\Behat\Tester\Exception\PendingException;
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\MinkExtension\Context\MinkContext; 
#use Behat\MinkContext\Context\RawMinkContext;

class FeatureContext extends MinkContext implements Context,   SnippetAcceptingContext
{

/**
 * @Given I am in wikipedia
 */
public function iAmInWikipedia()
{
    $this->visitPath("/");
}

/**
 * @When I search for :arg1
 */
public function iSearchFor($arg1)
{
    throw new PendingException();
}

/**
 * @Then the first heading should be :arg1
 */
public function theFirstHeadingShouldBe($arg1)
{
    throw new PendingException();
}
}

您还需要将您的上下文添加到behat.yml默认上下文中。

在同一级别的extensions之前,添加:

suites:
 default:
  contexts:
    - FeatureContext

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM