Codeception的测试覆盖率报告为空,尽管测试运行正常。

4

enter image description hereCodeception.yml 配置:

paths:
    tests: src/Niwa/ForecastUIBundle/Tests/codecept/test
    log: app/logs/report
    data: src/Niwa/ForecastUIBundle/Tests/codecept/test/_data
    helpers: src/Niwa/ForecastUIBundle/Tests/codecept/test/_helpers
settings:
    bootstrap: _bootstrap.php
    suite_class: \PHPUnit_Framework_TestSuite
    colors: true
    memory_limit: 1024M
    log: true

coverage:
    enable: true
    remote: true
    include:
        - src/Niwa/ForecastUIBundle
        - src/Niwa/ForecastRestBundle

我接受的 acceptance.suite.yml 文件配置:

# Codeception Test Suite Configuration

# suite for acceptance tests.
# perform tests in browser using the Selenium-like tools.
# powered by Mink (http://mink.behat.org).
# (tip: that's what your customer will see).
# (tip: test your ajax and javascript by one of Mink drivers).

# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.

class_name: WebGuy
modules:
    enabled:
        - PhpBrowser
        - WebHelper
        - WebDebug
    config:
        PhpBrowser :
         url: 'http://forecast.localhost'

        capabilitites:
          unexpectedAlertBehaviour: 'accept'

我正在运行的命令以获取测试覆盖率:

php ./codecept.phar run --coverage --xml --html --report

输出:

Codeception PHP Testing Framework v1.8.3
Powered by PHPUnit 3.7.28 by Sebastian Bergmann.
test the big number page (BigNumberTestCept.php)...........................Ok
display niwa forecast chart (ForecastChartCept.php)........................FAIL
check the resize algorithm (ForecastChartResizeCept.php)...................Ok
test the resize algorithm (LandingPageCept.php)............................FAIL


Code Coverage Report 
  2014-04-14 16:09:02

 Summary: 
  Classes:  (0/0)
  Methods:  (0/0)
  Lines:    (0/0)

它返回的是空白的index.html,没有展示任何类和方法,也没有生成任何报告。
请帮忙解决!!!

有任何 Codecept 专家吗?请。 - shab
3个回答

2
将 coverage.remote 设为 false。如果在本地测试,无需将 remote 设为 true。
我在 GitHub 上看到了你的问题https://github.com/Codeception/Codeception/issues/976,并且你的项目根目录中有 c3.php 文件。在我的情况下,如果 c3.php 文件位于项目根目录或网站根目录中,就会出现问题。我不得不将此文件移动到其他目录,因为在代码覆盖期间,Codeception 会对 /c3/* 路径发出请求,如果我在项目根目录或网站目录中有 c3.php 文件,则这些路径对我无效。

1

所以我相信问题出在命令行(codeception中的错误)

php ./codecept.phar run --coverage --xml --html --report

我无法使用"--xml","--html"和"--report"生成报告。我正在使用Jenkins,因此我使用以下内容:

php ./codecept.phar run --coverage --xml

本地开发。
php ./codecept.phar run --coverage --html

然后我可以在_log/report.html和_log/coverage/index.html中查看HTML报告。


我可以看到report.html显示了结果,但是index.html仍然显示空的类。 - shab
我不确定是否注意到你的配置是设置为远程。你可能需要查看你的远程服务器Apache/PHP错误日志,以查看c3.php调用是否实际执行。 - Clutch

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接