【发布时间】: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