php - Codeception 验收测试报告覆盖率为 0%
问题描述
我正在尝试通过 codeception 测试我的 Yii2 应用程序。我想查看我的代码的覆盖率。我正在运行硒服务器:
java -jar -Dwebdriver.chrome.driver=chromedriver /path/to/selenium-server-standalone-3.141.59.jar
我正在通过以下方式运行我的测试:
./vendor/bin/codecept run `tests/acceptance/callIn/FinishCallCest.php:submitBlank --coverage`
当我在没有一切正常的情况下运行代码接收验收测试时。如果我正在运行代码接收单元测试,我会得到正确的覆盖率报告。 --coverage
--coverage
但是,如果我运行 codeception 验收测试,--coverage
我会看到以下内容:
- localhost:8080 链接在我的浏览器中打开。我看到来自 Yii2 的“NOT FOUND 404”页面。
- 然后重定向到http://localhost:8080/index-test.php?r=call-in%2Ffinish-call&callId=1 发生,我看到页面并且测试成功完成。
为什么 localhost:8080 页面首先加载?以及如何修复覆盖率为 0% 的错误?
这是我的codeception.yml
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
helpers: tests/_support
settings:
bootstrap: _bootstrap.php
memory_limit: 1024M
colors: true
modules:
config:
Yii2:
configFile: 'config/test.php'
cleanup: false
coverage:
c3_url: http://127.0.0.1:8080/index-test.php/
enabled: true
whitelist:
include:
- models/*
- controllers/*
config:
test_entry_url: http://localhost:8080/idnex-test.php
这是我的acceptance.suite.yml
class_name: AcceptanceTester
modules:
enabled:
- Yii2:
part: [orm] # allow to use AR methods
cleanup: false
- WebDriver:
url: 'http://test:test@localhost:8080'
auth: ['test', 'test']
browser: chrome
restart: true
window_size: 1024x768
这是一个代码接收测试日志:
Acceptance Tests (1) ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Modules: Yii2, WebDriver
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FinishCallCest: Submit blank finish form
Signature: calIn\FinishCallCest:submitBlankFinishForm
Test: tests/acceptance/callIn/FinishCallCest.php:submitBlankFinishForm
Scenario --
Destroying application
Starting application
[ConnectionWatcher] watching new connections
[Fixtures] Loading fixtures
[Fixtures] Done
[GET] http://test:test@localhost:8080/
[Cookies] [{"domain":"localhost","httpOnly":true,"name":"_csrf","path":"/","secure":false,"value":"c99eee70d806de0660302db950c436a04f5a6316b5847caed6de7d1d2e2d896aa%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%22PXMEKYNF-k-StsR38slXolelVVLuFKTK%22%3B%7D"},{"domain":"localhost","expiry":1543848123.606772,"httpOnly":true,"name":"_identity","path":"/","secure":false,"value":"dacb46519512cd901d6c8ceafb494a3d2893b6cf41a196e111c9c522aa4605c9a%3A2%3A%7Bi%3A0%3Bs%3A9%3A%22_identity%22%3Bi%3A1%3Bs%3A77%3A%22%5B%22corebofs000080000ktnhd8g9vnbio68%22%2C%22corebofs000080000ktnhd8g9vnbio68%22%2C18000%5D%22%3B%7D"},{"domain":"localhost","httpOnly":true,"name":"PHPSESSID","path":"/","secure":false,"value":"06okm3re6q6ncjj6q878sdq88j"}]
I am on page "/index-test.php?r=call-in%2Ffinish-call&callId=1"
[GET] http://test:test@localhost:8080/index-test.php?r=call-in%2Ffinish-call&callId=1
I wait 5
I click "//*[@id="w3"]/div[1]/div[1]/h4/a"
I wait 5
I see "Завершение звонка","//*[@id="w1"]/div[4]/button"
I click "//*[@id="w1"]/div[4]/button"
PASSED
Destroying application
[ConnectionWatcher] no longer watching new connections
[ConnectionWatcher] closing all (0) connections
Suite done, restoring $_SERVER to original
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Time: 24.18 seconds, Memory: 14.00MB
OK (1 test, 1 assertion)
Code Coverage Report:
2018-12-03 09:42:01
Summary:
Classes: 0.00% (0/84)
Methods: 0.00% (0/389)
Lines: 0.00% (0/2706)
Remote CodeCoverage reports are not printed to console
HTML report generated in coverage
解决方案
推荐阅读
- sql - 如何根据 postgresql 中的另一列对字符串聚合进行排序?
- android - 错误:cmd:将应用程序运行到 android apk 时命令失败,退出代码为 ENOENT
- python - 使用带有 TimeDistributed LSTM 层的 CNN 编码器来解决拼图问题
- html - 无法从滚动中冻结带有 CSS 的两个第一列
- python - 从未知多项式函数中找到系数的最优解
- css - Safari 切断虚线边框的第一个和最后一个破折号
- elasticsearch - 如何在两个单独的服务器之间使用 Logstash 将日志从文件发送到 Elasticsearch?
- r - 将复杂数据从一个 Dataframe 获取到另一个 Dataframe
- java - Java,硒超时异常
- vb.net - 表单在 vb.net 中加载缓慢