문제

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%

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?

도움이 되었습니까?

해결책 2

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

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: will generate the report in HTML format

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

--coverage-clover: will generate a clover report

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

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

다른 팁

With Phing's own PHPunit task being used, you could potentially use CoverageThresholdTask (http://www.phing.info/docs/guide/stable/apcs05.html)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top