【问题标题】:Codeception functional and acceptance test errorsCodeception 功能和验收测试错误
【发布时间】:2014-08-17 17:51:32
【问题描述】:

我正在一个 vagrant box 上运行最新版本的 Codeception,但我无法进行验收或功能测试。

这里是acceptance.suite.yml

class_name: AcceptanceTester
modules:
    enabled:
        - PhpBrowser
        - AcceptanceHelper
    config:
        PhpBrowser:
            url: 'http://test.dev'

还有我的验收测试:

$I = new AcceptanceTester($scenario);
$I->wantTo('check Codeception');

$I->amOnPage('/');

$I->see('hello');

索引页面是一个简单的 html 输出,带有“hello world”

我得到的错误如下:

1) Failed to check codeception in testTestCept (/vagrant/test/tests/acceptance/testTestCept.php)
Sorry, I couldn't am on page "http://test.dev/":
GuzzleHttp\Exception\RequestException: cURL error 6: Couldn't resolve host 'test.dev'

Scenario Steps:
1. I am on page "http://test.dev/"

#1  /vagrant/fmx/vendor/guzzlehttp/guzzle/src/Adapter/Curl/CurlAdapter.php:91
#2  /vagrant/fmx/vendor/guzzlehttp/guzzle/src/Adapter/StreamingProxyAdapter.php:34
#3  /vagrant/fmx/vendor/guzzlehttp/guzzle/src/Client.php:186
#4  /vagrant/fmx/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Client.php:332
#5  /vagrant/fmx/tests/acceptance/AcceptanceTester.php:128
#6  /vagrant/fmx/tests/acceptance/testTestCept.php:5
#1  /vagrant/fmx/vendor/guzzlehttp/guzzle/src/Adapter/Curl/CurlAdapter.php:91
#2  /vagrant/fmx/vendor/guzzlehttp/guzzle/src/Adapter/StreamingProxyAdapter.php:34
#3  /vagrant/fmx/vendor/guzzlehttp/guzzle/src/Client.php:186
#4  /vagrant/fmx/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Client.php:332
#5  /vagrant/fmx/tests/acceptance/AcceptanceTester.php:128
#6  /vagrant/fmx/tests/acceptance/testTestCept.php:5

我的功能测试同样简单:

$I = new FunctionalTester($scenario);
$I->wantTo('check Codeception');

$I->amOnPage('/');

$I->see('hello');

有了这个我得到以下错误:

There was 1 error:

---------
1) Failed to check codeception in testTestCept (/vagrant/test/tests/functional/testTestCept.php)
#1  /vagrant/test/tests/functional/testTestCept.php:5
#2  /vagrant/test/tests/functional/testTestCept.php:5

第 5 行具体为:$I->amOnPage('/');

我是 vagrant 的新手,所以我不确定我是否错过了设置中的某些内容,或者我是否做错了什么。我正在通过vagrant ssh 运行代码接收。

更新:

我们已经进行了验收测试。现在只关注功能测试。根据要求,以下是完整的functional.suite.yml 内容。由于我是分阶段设置的,因此我实际上并没有对此进行修改:

# Codeception Test Suite Configuration

# suite for functional (integration) tests.
# emulate web requests and make application process them.
# Include one of framework modules (Symfony2, Yii2, Laravel4) to use it.

class_name: FunctionalTester
modules:
    enabled: [Filesystem, FunctionalHelper]

【问题讨论】:

  • 我认为amOnPage() 方法不能接受完整的网址。尝试amOnPage('/') 进行验收测试(功能是另一种情况,所以还有另一个问题)。
  • Sorry Phantom:我确实尝试了两种方式,但我错过了输出上的编辑以正确显示它我使用了amOnPage('/'),但它仍然没有工作。
  • 试试url: 'http://test.dev:80'
  • 试过@The Shift Exchange,但没有成功。结果相同:/
  • 因为您在 vagrant 中运行代码接收 - 也许它需要是“localhost”或“192.168.0.1”或类似的东西。检查您在 vagrant 中的设置以获取网站地址

标签: php testing codeception


【解决方案1】:

我遇到了同样的问题,这对我有帮助:

unable to run codeception in virtual machine -Mink could not be found and loaded

我需要在我的 /etc/hosts 文件中为我的 vm 中的站点添加一个条目。

【讨论】:

  • 哇!这适用于我的验收测试,但我的功能测试仍然失败。代码接收中是否还有其他地方我必须更新路径? ://
  • 我对此表示怀疑,因为功能测试不使用网络服务器。您可以发布您的functional.suite.yml 文件吗?
  • 已添加,但与初始安装时相同。我还没有在这里改变任何东西。仍然是相同的amOnPage() 导致错误,因为它在验收测试中,这就是为什么我希望它们是相关的:/
  • 我可能是错的,但看起来您的模块中没有设置框架。您是否浏览过此处找到的文档:Functional Test Documentation?它将引导您设置functional.suite.yml 文件。
猜你喜欢
  • 2013-06-10
  • 2015-05-25
  • 1970-01-01
  • 2011-03-23
  • 2014-02-01
  • 1970-01-01
  • 2016-11-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多