【问题标题】:codeception coverage report is empty though the test runs尽管测试运行,但代码接收覆盖率报告为空
【发布时间】:2014-05-27 22:21:37
【问题描述】:

codeception.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 都设置为空白。不生成任何报告。

请帮忙!!!

【问题讨论】:

  • 任何密码专家?请

标签: symfony phpunit code-coverage codeception


【解决方案1】:

将coverage.remote 设置为false。如果您在本地测试,则无需将 remote 设置为 true。

正如我在 GitHub https://github.com/Codeception/Codeception/issues/976 上看到您的问题,并且您在项目根目录中有 c3.php。就我而言,如果我在项目根目录或 Web 根目录中有 c3.php 文件,我会遇到问题。我不得不将此文件移动到其他目录,因为在代码覆盖期间 Codeception 会请求 /c3/* 路径,如果我在项目根目录或 web 目录中有 c3.php 文件,这些路径对我不起作用。

【讨论】:

    【解决方案2】:

    所以我认为问题出在命令行(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 仍然显示空类。
    • 我不确定我是否注意到您的配置是使用远程设置的。您可能需要查看远程服务器 Apache/PHP 错误日志以查看 c3.php 调用是否实际执行。
    【解决方案3】:

    你在设置指令“启用”时犯了一个错误。

    enable: true 更改为enabled: true,代码覆盖率收集将起作用。 http://codeception.com/docs/11-Codecoverage#Configuration

    【讨论】:

      猜你喜欢
      • 2015-12-14
      • 1970-01-01
      • 2017-09-03
      • 2017-03-23
      • 2017-10-25
      • 2012-01-07
      • 2019-09-19
      • 2019-09-02
      • 1970-01-01
      相关资源
      最近更新 更多