ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

在第81行的vendor / behat / mink-extension / src / Behat / MinkExtension / Context / RawMinkContext.php中的

2019-10-03 06:29:02  阅读:173  来源: 互联网

标签:behat mink php


尝试从命令行运行我的behat测试时出现此错误.

错误的完整输出如下所示:

$behat                                       
Feature: View a list of current custom tariffs
    In order to provide custom call pricing to customers
    As a user of the Voxbeam Admin site
    I expect to be able to correctly administrate a users custom tariffs

  @sahi
  Scenario: Listing existing custom tariffs # features/custom_tariff_admin.feature:7
PHP Fatal error:  Call to a member function getSession() on a non-object in /Users/stuart/bin/vendor/behat/mink-extension/src/Behat/MinkExtension/Context/RawMinkContext.php on line 81
PHP Stack trace:
PHP   1. {main}() /Users/stuart/bin/vendor/behat/behat/bin/behat:0
PHP   2. Symfony\Component\Console\Application->run() /Users/stuart/bin/vendor/behat/behat/bin/behat:32
PHP   3. Behat\Behat\Console\BehatApplication->doRun() /Users/stuart/bin/vendor/symfony/console/Symfony/Component/Console/Application.php:106
PHP   4. Symfony\Component\Console\Application->doRun() /Users/stuart/bin/vendor/behat/behat/src/Behat/Behat/Console/BehatApplication.php:68
PHP   5. Symfony\Component\Console\Command\Command->run() /Users/stuart/bin/vendor/symfony/console/Symfony/Component/Console/Application.php:193
PHP   6. Behat\Behat\Console\Command\BehatCommand->execute() /Users/stuart/bin/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:240
PHP   7. Behat\Behat\Console\Command\BehatCommand->runFeatures() /Users/stuart/bin/vendor/behat/behat/src/Behat/Behat/Console/Command/BehatCommand.php:128
PHP   8. Behat\Gherkin\Node\AbstractNode->accept() /Users/stuart/bin/vendor/behat/behat/src/Behat/Behat/Console/Command/BehatCommand.php:150
PHP   9. Behat\Behat\Tester\FeatureTester->visit() /Users/stuart/bin/vendor/behat/gherkin/src/Behat/Gherkin/Node/AbstractNode.php:42
PHP  10. Behat\Gherkin\Node\AbstractNode->accept() /Users/stuart/bin/vendor/behat/behat/src/Behat/Behat/Tester/FeatureTester.php:88
PHP  11. Behat\Behat\Tester\ScenarioTester->visit() /Users/stuart/bin/vendor/behat/gherkin/src/Behat/Gherkin/Node/AbstractNode.php:42
PHP  12. Behat\Behat\Tester\ScenarioTester->visitStep() /Users/stuart/bin/vendor/behat/behat/src/Behat/Behat/Tester/ScenarioTester.php:87
PHP  13. Behat\Gherkin\Node\AbstractNode->accept() /Users/stuart/bin/vendor/behat/behat/src/Behat/Behat/Tester/ScenarioTester.php:148
PHP  14. Behat\Behat\Tester\StepTester->visit() /Users/stuart/bin/vendor/behat/gherkin/src/Behat/Gherkin/Node/AbstractNode.php:42
PHP  15. Behat\Behat\Tester\StepTester->executeStep() /Users/stuart/bin/vendor/behat/behat/src/Behat/Behat/Tester/StepTester.php:95
PHP  16. Behat\Behat\Tester\StepTester->executeStepDefinition() /Users/stuart/bin/vendor/behat/behat/src/Behat/Behat/Tester/StepTester.php:126
PHP  17. Behat\Behat\Definition\Annotation\Definition->run() /Users/stuart/bin/vendor/behat/behat/src/Behat/Behat/Tester/StepTester.php:157
PHP  18. call_user_func_array() /Users/stuart/bin/vendor/behat/behat/src/Behat/Behat/Definition/Annotation/Definition.php:155
PHP  19. Behat\MinkExtension\Context\MinkContext->visit() /Users/stuart/bin/vendor/behat/behat/src/Behat/Behat/Definition/Annotation/Definition.php:155
PHP  20. Behat\MinkExtension\Context\RawMinkContext->getSession() /Users/stuart/bin/vendor/behat/mink-extension/src/Behat/MinkExtension/Context/MinkContext.php:45

我的behat.yml是:

# behat.yml
default:
    paths:
        features: features
        bootstrap: %behat.paths.features%/bootstrap
    extensions:
        Behat\MinkExtension\Extension:
            base_url:  'http://dev.example.com'
            goutte: ~
            sahi: ~

annotations:
  paths:
    features: features/annotations

closures:
  paths:
    features: features/closures

我有一个非常简单的FeatureContext:

<?php

use Behat\Behat\Context\ClosuredContextInterface,
    Behat\Behat\Context\BehatContext,
    Behat\Behat\Exception\PendingException,
    Behat\Behat\Context\Step;

use Behat\Gherkin\Node\PyStringNode,
    Behat\Gherkin\Node\TableNode;

use Behat\MinkExtension\Context\MinkContext;

//
// Require 3rd-party libraries here:
//
//   require_once 'PHPUnit/Autoload.php';
//   require_once 'PHPUnit/Framework/Assert/Functions.php';
//

/**
 * Features context.
 */
class FeatureContext extends MinkContext
{
    /**
     * @Given /^I am logged in as "([^"]*)" with password "([^"]*)"$/
     */
    public function iAmLoggedInAsWithPassword($userName, $password) 
    {
        return array(
            new Step\Given('I am on "/login"'),
            new Step\Given('I should see "fert"')
        );
    }

//
// Place your definition and hook methods here:
//
//    /**
//     * @Given /^I have done something with "([^"]*)"$/
//     */
//    public function iHaveDoneSomethingWith($argument)
//    {
//        doSomethingWith($argument);
//    }
//
}

和一个同样简单的功能:

Feature: Administer a customers custom tariffs
    In order to provide custom call pricing to customers
    As a user of the Admin site
    I expect to be able to correctly administrate a users custom tariffs

Scenario: Listing existing custom tariffs
    Given I am on "/"
    I should see "Fert"

解决方法:

确保您的behat.yml文件位于正确的位置.它应该在项目的根目录中,而不是在任何子目录中.

标签:behat,mink,php
来源: https://codeday.me/bug/20191003/1847433.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有