php-Codeception无法构建在全局配置中配置的模块
作者:互联网
我在我的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,则该模块根本不会运行.似乎全局配置的模块部分被完全忽略了.如果全局配置中Db中有错字,它甚至不会影响任何东西.但是对于每个套件和每个应用程序,我只需要为Db配置一个配置.我究竟做错了什么?文档说应该可以全局声明模块.
解决方法:
好的,澄清一下:这是我的codecetion.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和dcr-static.
>在“迷你”中,没有提供DataHelper配置,因此它使用的是codecetion.yml文件中的配置.
>在“ dcr-static”中,我为此环境提供了另一种配置,该配置被使用,而不是codecetion.yml文件中给定的配置.
标签:codeception,unit-testing,php 来源: https://codeday.me/bug/20191119/2037905.html