我的codeception.yml
在测试根文件夹配置:
include:
- codeception/backend
- codeception/common
- codeception/console
paths:
log: codeception/_output
settings:
colors: true
modules:
enabled:
- Db
config:
Db:
dsn: 'mysql:host=localhost;dbname=db1_test'
user: 'root'
password: 'qwerty'
cleanup: true
那么在mu codeception/codeception.yml
中:
namespace: tests'codeception'backend
actor: Tester
paths:
tests: .
log: _output
data: _data
helpers: _support
settings:
bootstrap: _bootstrap.php
suite_class: 'PHPUnit_Framework_TestSuite
colors: true
memory_limit: 1024M
log: true
config:
# the entry script URL (without host info) for functional and acceptance tests
# PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
test_entry_url: http://ds3/index-test.php
然后在我的codeception/unit.suite.yml
中:
class_name: UnitTester
modules:
enabled:
- Db
但是当我从测试根文件夹运行codecept build
时,我得到以下错误:
[Codeception'Exception'ModuleConfigException]
Db module is not configured!
Options: dsn, user, password are required
Please, update the configuration and set all the required fields
如果我从codeception/unit.suite.yml
中删除- Db
,模块根本不运行。似乎全局配置的modules
部分被完全忽略了。如果在全局配置中Db
有一个错别字,它甚至不会影响任何事情。但我需要只有一个配置Db为每个套件和每个应用程序。我做错了什么?文档中说应该可以全局声明模块
好,澄清一下:这是我的欺骗。Yml文件(与上面的项目不同,但针对您的场景进行了测试):
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
helpers: tests/_support
settings:
bootstrap: _bootstrap.php
colors: false
memory_limit: 1024M
modules:
config:
DataHelper:
db:
host: 02corm.za.ds.xxxxxxx.com
user: xxxxxxx
password: yyyyyyy
port: 3306
env:
stubDelay: 2
otdWebhook: http://xxxxxx.com:9080/api/webhook/
otdStubUrl: http://xxxxxx.com:9080/api/
和我的api.suite.yml:
class_name: ApiTester
modules:
enabled:
- PhpBrowser
- REST
- ApiHelper
- DataHelper
- CurlHelper
- OtdHelper
- Asserts
- WooCommerceHelper
- ResponseHelper
config:
PhpBrowser:
url: http://dev.xxxx.co.za
curl:
CURLOPT_TIMEOUT: 50000 # timeout in seconds
REST:
url: http://dev.xxxx.co.za
timeout: 90
env:
mini:
modules:
config:
PhpBrowser:
url: http://xxxxxx.com:9080/api/
curl:
CURLOPT_TIMEOUT: 50000 # timeout in seconds
REST:
url: http://xxxxxx.com:9080/api/
dcr-static:
modules:
config:
PhpBrowser:
url: http://x.x.x.x:10080/api
curl:
CURLOPT_TIMEOUT: 50000 # timeout in seconds
REST:
url: http://x.x.x.x:10080/api
DataHelper:
db:
host: x.x.x.x
user: xxxxx
password: yyyy
port: 3307
env:
stubDelay: 2
otdWebhook: http://x.x.x.x:10080/api/webhook/otd
otdStubUrl: http://x.x.x.x:10080/otd-stub/service
在上述设置中,我有两个环境:mini和dr -static。
在'mini'中没有提供DataHelper配置,因此它正在使用来自co欺骗的配置。yml文件。
在' dr -static'中,我为这个环境提供了一个替代配置,它被用来代替co欺骗中给出的配置。yml文件
看起来应该是这样的:
class_name: UnitTester
modules:
enabled:
- Db
config:
Db:
dsn: 'mysql:host=localhost;dbname=db_name_here;port=3306'
user: 'user_here'
password: 'password_here'
dump: ''
populate: false
cleanup: false
reconnect: true
我刚刚遇到了同样的问题,并通过一次运行一个套件来解决它。只有当我试图一次运行所有套件时,Codeception才无法正确加载配置。