簡體   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