如果代码覆盖率低于85%,则停止phing部署 [英] Stop phing deployment if code coverage is below 85%

查看:109
本文介绍了如果代码覆盖率低于85%,则停止phing部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用phing部署我的php代码,但是如果任何一个PHP单元测试用例失败或代码覆盖率小于85%,我们需要添加一个条件来停止部署

Am using a phing to deploy my php code but we need to add a condition to stop the deployment if any of the PHP Unit test cases fails or code coverage is less than 85%

我们能够通过在build.xml中添加以下代码来添加PHP单元测试用例条件

We were able to add the PHP Unit test case condition by adding following code in built.xml

<phpunit  haltonerror="true" haltonfailure="true" printsummary="true">
</phpunit>

现在我需要测试代码覆盖率,请让我知道我该怎么做?

Now i need to test for the code coverage percentage, Please let me know how can i do that?

推荐答案

要获取代码覆盖率百分比,可以使用三叶草报告,该报告将生成xml文件.

To get the code coverage Percentage you can use clover Report, which will generate xml file.

从xml文件中,您可以阅读声明 coveredstatements ,它们将构成您的总百分比

From the xml file you can read the Statements and coveredstatements which will constitute you Total percentage

三叶草报告可以使用以下命令生成:

Clover Report can be generated using following command:

phpunit  --coverage-html ./code_Coverage_Report --coverage-clover ./cloverReport.xml codecoverage_test/CodeCoverage.php

-coverage-html :将以HTML格式生成报告

--coverage-html: will generate the report in HTML format

./code_Coveerage_Report :将创建一个文件夹,并在该文件夹内生成coverage三叶草报告

./code_Coveerage_Report: will create a folder and the coverage clover report will be generate inside that folder

-coverage-clover :将生成三叶草报告

./cloverReport.xml :将为三叶草报告生成xml文件

./cloverReport.xml: will generate an xml file for clover report

codecoverage_test/CodeCoverage.php :我需要为其生成覆盖率报告的文件

codecoverage_test/CodeCoverage.php: The file for which i need to generate coverage report

这篇关于如果代码覆盖率低于85%,则停止phing部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆