[英]Codeception namespaces
Currently we have a large acceptance suite built using Codeception 2.0.16.目前我们有一个使用 Codeception 2.0.16 构建的大型验收套件。 We would like to upgrade to Codeception 2.2.5.
我们想升级到 Codeception 2.2.5。 However, after installing Codeception 2.2.5 (via phar), we cannot run our test suites at all.
但是,在安装 Codeception 2.2.5(通过 phar)之后,我们根本无法运行我们的测试套件。
The error we receive is (additional details at bottom):我们收到的错误是(底部的其他详细信息):
[Codeception\\Exception\\ConfigurationException] Module WebHelper could not be found and loaded
[Codeception\\Exception\\ConfigurationException] 无法找到和加载模块 WebHelper
Obviously the new version has loading changes that affect our suite.显然,新版本的加载更改会影响我们的套件。
I have searched for migration instructions to help us with this upgrade and don't see any.我搜索了迁移说明以帮助我们进行此升级,但没有看到任何说明。
Addtional Details其他详细信息
Codeception PROJECT configuration Codeception PROJECT 配置
Note: After testing and changing several parts of the code i noticed that the main problem is related to namespaces.注意:在测试和更改代码的几个部分后,我注意到主要问题与命名空间有关。 As you can se below we are using a namespace called "SM" and some how this os causing problems.
正如您在下面看到的,我们使用了一个名为“SM”的命名空间,以及这个操作系统如何导致问题。
codeception.yml代码接收.yml
namespace: SM
paths:
tests: tests
log: tests/_log
data: tests/_data
helpers: tests/_helpers
settings:
bootstrap: _bootstrap.php
suite_class: \PHPUnit_Framework_TestSuite
colors: true
memory_limit: 1024M
log: true
strict_xml: true
modules:
config:
Db:
dsn: 'mysql:host=xxxxxxxxxxxx;dbname=<DB_NAME>'
user: 'USER'
password: '********'
dump: tests/_data/dump.sql
populate: false
cleanup : false
Acceptance Suite configuration验收套件配置
class_name: WebGuy
modules:
enabled:
- WebDriver
- WebHelper
- SistemWSClient
- TestingSupportWSClient
- Db
- TempFileManager
- Asserts
config:
WebDriver:
url: 'http://xxxxxxxxxxxxxxxxxx/codeception'
browser : firefox
host: xxxxxxxxxxxxx
port: 4444
wait: 0
restart: true
capabilities:
unexpectedAlertBehaviour: 'accept'
SistemWSClient:
url: xxxxxxx
TestingSupportWSClient:
url: 'http://x/codeception/rest.php'
Db:
dsn: 'mysql:host=xx;port=3306;dbname=x'
user: 'xxxxxxx'
password: 'xxxxxxx'
dump: 'some/dump/file'
populate: false
cleanup: false
Notes:笔记:
a) I have added "namespace SM;" a)我添加了“命名空间 SM”; at the top of tests/_helpers/WebHelper.php (it did not work)
在 tests/_helpers/WebHelper.php 的顶部(它不起作用)
b) I also tried this: (it did not work) b)我也试过这个:(它没有用)
modules:
enabled:
- \WebHelper (or \SM\WebHelper or any other combination)
c) I also installed a cleaned version of codeception from codeception's site: c)我还从 codeception 的站点安装了一个清理过的 codeception 版本:
Added "namespace SM;"添加了“命名空间 SM;” and Helpers accordingly and i get the same error, in this case:
和助手相应地,我得到同样的错误,在这种情况下:
Helper\\Acceptance could not be found and loaded
无法找到并加载 Helper\\Acceptance
d) I also tried to use codeception's "add-namespace" command without luck d)我也尝试使用 codeception 的“add-namespace”命令,但没有成功
Any idea will be appreciated.任何想法将不胜感激。
Thanks,谢谢,
In Codeception, the 'helpers' have to be built.在 Codeception 中,必须构建“助手”。 Try issuing the command:
尝试发出以下命令:
codecept build
Then run it again.然后再次运行它。
The error in my case mentioned another file, however the reason and the solution may be the same.我的情况下的错误提到了另一个文件,但是原因和解决方案可能相同。
After a few hours of debugging and searching the web I found the answer to my problem at least: http://phptest.club/t/class-helper-acceptance-does-not-exist/808经过几个小时的调试和网络搜索,我至少找到了问题的答案: http : //phptest.club/t/class-helper-acceptance-does-not-exist/808
In my case, my main-projects's .gitignore had a _*
line in it.就我而言,我的主要项目的 .gitignore 中有一个
_*
行。 Because of this the codeception directories had not been committed, and specifically the _support directy containing the requested file.因此,尚未提交 codeception 目录,特别是包含所请求文件的 _support 目录。
Removing the _*
line from my .gitignore and committing and pulling the files, then fixed the problem.从我的 .gitignore 中删除
_*
行并提交和拉取文件,然后解决了问题。
Hope this helps.希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.