我使用Composer重新安装了Luracast/Restler,但无法运行任何behat测试。我是Restler和behat的新手,所以我可能犯了一个初学者的错误,但根据文档,我所需要做的就是在behat.yml中更改根URL,然后输入bin/behat。
这是我在输入vendor/bin/behat时得到的错误消息。
[RuntimeException]
Context class not found.
Maybe you have provided a wrong or no `bootstrap` path in your behat.yml:
http://docs.behat.org/guides/7.config.html#paths
behat [--init] [-f|--format="..."] [--out="..."] [--lang="..."] [--[no-]ansi] [--[no-]time] [--[no-]paths] [--[no-]snippets] [--[no-]snippets-paths] [--[no-]multiline] [--[no-]expand] [--story-syntax] [-d|--definitions="..."] [--name="..."] [--tags="..."] [--cache="..."] [--strict] [--dry-run] [--stop-on-failure] [--rerun="..."] [--append-snippets] [--append-to="..."] [features]
Content-type: text/html这是我的behat.yml文件:
# behat.yml
default:
context:
parameters:
base_url: http://<MY_DOMAIN>.com/restler3/sampleproject/public我尝试用绝对路径和相对路径指定paths.features和path.bootstrap变量,但都没有成功。
# behat.yml
default:
paths:
features: features
bootstrap: features/bootstrap
context:
parameters:
base_url: http://<MY_DOMAIN>.com/restler3/sampleproject/public我真的很想为我正在启动的一个API项目使用Restler,但我需要能够运行测试,所以任何帮助我解决这个问题的帮助都将不胜感激。
发布于 2014-08-07 17:11:27
您是否使用behat --init设置Behat
Behat需要功能和引导目录才能运行。您可以通过在命令行中输入behat --init来创建它们。有关这方面的详细信息,请参阅Behat documentation:
创建一个新目录并在该目录中设置behat:
$ mkdir ls_project $ cd ls_project $ behat --init
behat --init将创建一个features/目录,其中包含一些入门所需的基本内容。
Behat将为测试文件中的每一行运行一个测试方法。这些方法包含在上下文中。要编写在Restler examples中使用的功能测试,您需要使用Restler附带的"RestContext“。将vendor/luracast/restler/features/bootstrap的内容复制到您的Behat引导目录中,以便能够使用这些内容(您还需要FeatureContext.php:这将实例化RestContext)。
Restler的功能测试使用了Guzzle,因此您还需要将其添加到composer.json中
{
"require-dev": {
"guzzlehttp/guzzle": "~3.1.1"
}
}https://stackoverflow.com/questions/20897100
复制相似问题