Php “行为测试”;然后我会看到拉威尔5“;在laravel应用程序中失败

Php “行为测试”;然后我会看到拉威尔5“;在laravel应用程序中失败,php,laravel,laravel-5,bdd,behat,Php,Laravel,Laravel 5,Bdd,Behat,我有一个带OS El Capitan的Macbook。在我的新Laravel应用程序中(由创建) $composer创建项目laravel/laravel我的应用程序),我键入: $ php artisan serve 在localhost:8000上的浏览器(Safari或Chrome)中,我成功地在网页上看到黑色文本“Laravel 5” 我在features/中有一个hometest.feature文件,看起来像: Feature: In order to prove that Be

我有一个带OS El Capitan的Macbook。在我的新Laravel应用程序中(由创建)
$composer创建项目laravel/laravel我的应用程序
),我键入:

$ php artisan serve
在localhost:8000上的浏览器(Safari或Chrome)中,我成功地在网页上看到黑色文本“Laravel 5”

我在features/中有一个hometest.feature文件,看起来像:

Feature:
  In order to prove that Behat works as intended
  We want to test the home page for a phrase
  Scenario: Root Test
    When I am on the homepage
    Then I should see "Laravel 5"
<?php

use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;

/**
 * Defines application features from the specific context.
 */
class FeatureContext extends Behat\MinkExtension\Context\MinkContext implements Context, SnippetAcceptingContext
{
    /**
     * Initializes context.
     *
     * Every scenario gets its own context instance.
     * You can also pass arbitrary arguments to the
     * context constructor through behat.yml.
     */
    public function __construct()
    {
    }
}
default:
    extensions:
        Laracasts\Behat:
            # env_path: .env.behat
        Behat\MinkExtension:
            default_session: laravel
            base_url: http://localhost:8000
            laravel: ~
我有一个/features/bootstrap/FeaturesContext.php文件,看起来像:

Feature:
  In order to prove that Behat works as intended
  We want to test the home page for a phrase
  Scenario: Root Test
    When I am on the homepage
    Then I should see "Laravel 5"
<?php

use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;

/**
 * Defines application features from the specific context.
 */
class FeatureContext extends Behat\MinkExtension\Context\MinkContext implements Context, SnippetAcceptingContext
{
    /**
     * Initializes context.
     *
     * Every scenario gets its own context instance.
     * You can also pass arbitrary arguments to the
     * context constructor through behat.yml.
     */
    public function __construct()
    {
    }
}
default:
    extensions:
        Laracasts\Behat:
            # env_path: .env.behat
        Behat\MinkExtension:
            default_session: laravel
            base_url: http://localhost:8000
            laravel: ~
当我运行时(localhost running或not running=结果相同):

控制台输出为:

Feature:
  In order to prove that Behat works as intended
  We want to test the home page for a phrase

  Scenario: Root Test             # features/hometest.feature:5
    When I am on the homepage     # FeatureContext::iAmOnHomepage()
    Then I should see "Laravel 5" # FeatureContext::assertPageContainsText()
      The text "Laravel 5" was not found anywhere in the text of the current page. (Behat\Mink\Exception\ResponseTextException)

--- Failed scenarios:

    features/hometest.feature:5

1 scenario (1 failed)
2 steps (1 passed, 1 failed)
0m0.12s (20.26Mb)
为什么我简单的“我应该看到‘Laravel 5’测试失败?如果本地主机需要运行,我如何同时运行测试?当我启动本地主机时,我在终端中键入的任何内容都不会再收到响应

适用文件夹的我的目录结构:

app/
bootstrap/
...
features/
    bootstrap/
        FeatureContext.php
    hometest.feature
...
.env.behat
behat.yml
composer.json
...
etc.

谢谢!

最后!我通过我的服务器日志(storage/logs/laravel.log)发现呈现的页面包含文本“哎哟,好像出了问题。”(显然是错误的页面)。错误是“development.error:exception'RuntimeException',消息“找不到支持的加密程序”。密码和/或密钥长度无效。“” StackOverflow上有大约50个问题和答案,其中没有一个有效。经过几天的研究,我终于找到了我的解决方案。这可能是我以前所做更改的组合,也可能完全是由于这个命令。在任何情况下,请尝试:

php artisan config:cache

呸!

最后!我通过我的服务器日志(storage/logs/laravel.log)发现呈现的页面包含文本“哎哟,好像出了什么问题。”(显然是错误的页面)。错误是“development.error:exception'RuntimeException',消息“找不到支持的加密程序”。密码和/或密钥长度无效。“” StackOverflow上有大约50个问题和答案,其中没有一个有效。经过几天的研究,我终于找到了我的解决方案。这可能是我以前所做更改的组合,也可能完全是由于这个命令。在任何情况下,请尝试:

php artisan config:cache

呸!

我通过在env.behat文件中添加APP_键解决了这个问题

我通过在env.behat文件中添加APP_键解决了这个问题

为什么不通过另一个终端窗口运行测试?@RavishaHesh不幸的是,它在新窗口中输出了与我运行测试相同的消息,因为我不熟悉这个behat包。但在laravel phpunit中,有一个用于设置基本url的变量,该变量也不适用于localhost()的绝对路径。因此,它可能与虚拟主机有关。Behat.yml中
Behat\MinkExtension
下的
base\u url
的值是多少?更好的是,请将您的Behat.yml文件提供给我们。@MadDog我已经编辑了这篇文章,以包含Behat.yml和我的目录结构…看起来base\u url就是为什么不通过另一个终端窗口运行测试?@Ravish不幸的是,它在我运行测试的新窗口中输出了相同的消息。我不熟悉这个Behat包。但是在laravel phpunit中有一个变量用于设置基本url,并且它也不适用于localhost()的绝对路径。因此,它可能与一个虚拟主机有关。Behat.yml中
Behat\MinkExtension
下的
base\u url
的值是多少?更好的是,请给我们你的Behat.yml文件。@MadDog我已经编辑了这篇文章,包括了Behat.yml和我的目录结构…看起来base\u url是哦,我的上帝,我真是太感谢你了,兄弟。我已经帮了忙。我开始无缘无故地恨比哈特。再次感谢一百万你是英雄有同样的问题,现在已经解决了。感谢你:)哦,我的上帝,我真是太感谢你了,兄弟。我帮了忙。我开始无缘无故地恨比哈特。再次感谢一百万你是英雄,同样的问题,现在已经解决了。谢谢你:)