如何使用远程代码覆盖设置 Codeception?
How to setup Codeception with remote code coverage?
- 我的机器上有两个仓库
- API
- 测试API
的Codeception repo
在 API 回购中我添加了 codeception+c3
"require-dev": {
"codeception/codeception": "2.*",
"codeception/c3": "2.*",
我还在 index.php 中包含了 c3.php,但是在尝试使用 --coverage 对其进行测试时我遇到了这个错误
[PHPUnit_Framework_Exception]
file_get_contents(http://local.api.codeception.com/c3/report/clear): 辉
导致开流:HTTP请求失败! HTTP/1.1 500 内部服务器错误
是否有 任何 使用 Codeception 进行远程代码覆盖的在线示例?
好的,这是一个配置噩梦,但我已经修复了它
Here 是示例
这是我使用 Codeception 进行远程代码覆盖的配置 (Project on GitHub)。
运行 远程代码覆盖收集的步骤
1.确保已安装并启用 xdebug。
2。配置代码接收。
文件 codeception.yml
(GitHub):
coverage:
enabled: true
c3_url: 'http://%SERVICE_HOST%/index-test.php/'
include:
- web/*
- config/*
- src/*
3。为您需要的套装启用覆盖范围。
文件 acceptance.suite.yml
(GitHub):
coverage:
remote: true
在我的示例中,它仅为验收测试启用。
4。在您的应用程序中包含 c3.php
文件 bootstrap.
应用程序 bootstrap 文件 index-test.php
(GitHub):
// Start the remote code coverage collection.
require_once __DIR__.'/../c3.php';
// autoloader, application running and etc
// ...
5. 运行 覆盖率。
$ vendor/bin/codecept run --coverage --coverage-html
默认情况下,您可以在 tests/_output
目录中找到您的报告。
可能的问题
1.输出目录不可写 (tests/_output
).
$ chmod 777 tests/_output
2。控制台中未打印远程代码覆盖。
不应打印。来自文档:
coverage:
remote: true
In this case remote Code Coverage results won’t be merged with local ones, if this option is enabled. Merging is possible only in case a remote and local files have the same path. But in case of running tests on a remote server we are not sure of it.
3。其他一些错误。
尝试enable debug。如果启用调试,您可以获得报告或将其清除。
curl -o codecoverage.tar "http://localhost:8080/index-test.php/c3/report/html"
结束
有时这不是一项微不足道的任务。所以我希望这会有所帮助!
- 我的机器上有两个仓库
- API
- 测试API 的Codeception repo
在 API 回购中我添加了 codeception+c3
"require-dev": {
"codeception/codeception": "2.*",
"codeception/c3": "2.*",
我还在 index.php 中包含了 c3.php,但是在尝试使用 --coverage 对其进行测试时我遇到了这个错误
[PHPUnit_Framework_Exception] file_get_contents(http://local.api.codeception.com/c3/report/clear): 辉 导致开流:HTTP请求失败! HTTP/1.1 500 内部服务器错误
是否有 任何 使用 Codeception 进行远程代码覆盖的在线示例?
好的,这是一个配置噩梦,但我已经修复了它
Here 是示例
这是我使用 Codeception 进行远程代码覆盖的配置 (Project on GitHub)。
运行 远程代码覆盖收集的步骤
1.确保已安装并启用 xdebug。
2。配置代码接收。
文件 codeception.yml
(GitHub):
coverage:
enabled: true
c3_url: 'http://%SERVICE_HOST%/index-test.php/'
include:
- web/*
- config/*
- src/*
3。为您需要的套装启用覆盖范围。
文件 acceptance.suite.yml
(GitHub):
coverage:
remote: true
在我的示例中,它仅为验收测试启用。
4。在您的应用程序中包含 c3.php
文件 bootstrap.
应用程序 bootstrap 文件 index-test.php
(GitHub):
// Start the remote code coverage collection.
require_once __DIR__.'/../c3.php';
// autoloader, application running and etc
// ...
5. 运行 覆盖率。
$ vendor/bin/codecept run --coverage --coverage-html
默认情况下,您可以在 tests/_output
目录中找到您的报告。
可能的问题
1.输出目录不可写 (tests/_output
).
$ chmod 777 tests/_output
2。控制台中未打印远程代码覆盖。
不应打印。来自文档:
coverage: remote: true
In this case remote Code Coverage results won’t be merged with local ones, if this option is enabled. Merging is possible only in case a remote and local files have the same path. But in case of running tests on a remote server we are not sure of it.
3。其他一些错误。
尝试enable debug。如果启用调试,您可以获得报告或将其清除。
curl -o codecoverage.tar "http://localhost:8080/index-test.php/c3/report/html"
结束
有时这不是一项微不足道的任务。所以我希望这会有所帮助!