99designs/php-junit-merge
Composer 安装命令:
composer require 99designs/php-junit-merge
包简介
PHP-Unit J-Unit XML File Merger
README 文档
README
php-junit-merge is a library that merges multiple junit result xml files.
Installation
Simply add a dependency on andreas-weber/php-junit-merge to your project's composer.json file if you use Composer to manage the dependencies of your project.
Usage
After updating dependencies by composer a new binary php-junit-merge is available for usage.
root@dev:~/projects/sample/vendor/bin ./phpjunitmerge
phpjunitmerge 1.0.5 by Andreas Weber
Usage:
phpjunitmerge [--names="..."] [--ignore="..."] dir file
Arguments:
dir Directory where all files ready to get merged are stored
file The target file in which the merged result should be written
Options:
--names A comma-separated list of file names to check (default: "*.xml")
--ignore A comma-separated list of file names to ignore (default: "result.xml")
--help (-h) Display this help message
--quiet (-q) Do not output any message
--verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
--version (-V) Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
--no-interaction (-n) Do not ask any interactive question
--no-suffix Do not add suffix for test suites with duplicate names
The binary expects at least two parameters:
diris the directory, where the application should search for xml filesfileis the result file, in which the application should write the merged content
A simple call could look like this:
root@dev:~/projects/sample/vendor/bin ./phpjunitmerge src/Tests/Unit/Fixtures result.xml
phpjunitmerge 1.0.0 by Andreas Weber
Found and processed 3 files. Wrote merged content in 'result.xml'.
Example
Single Result Files
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="/Some_PHPUnit_Testsuite1" tests="2" assertions="2" failures="0" errors="0" time="1.234567">
<testsuite name="Unit\Testsuite2" file="/Unit/Testsuite1.php" tests="2" assertions="2" failures="0" errors="0" time="0.003623">
<testcase name="someRandomTestName1" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="8" assertions="1" time="0.002003"/>
<testcase name="someRandomTestName2" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="13" assertions="1" time="0.000795"/>
</testsuite>
</testsuite>
</testsuites>
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="/Some_PHPUnit_Testsuite2" tests="3" assertions="3" failures="0" errors="0" time="1.234567">
<testsuite name="Unit\Testsuite1" file="/Unit/Testsuite1.php" tests="3" assertions="3" failures="0" errors="0" time="0.003623">
<testcase name="someRandomTestName1" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="8" assertions="1" time="0.002003"/>
<testcase name="someRandomTestName2" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="13" assertions="1" time="0.000795"/>
<testcase name="someRandomTestName3" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="18" assertions="1" time="0.000825"/>
</testsuite>
</testsuite>
</testsuites>
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="/Some_PHPUnit_Testsuite3" tests="6" assertions="6" failures="0" errors="0" time="1.234567">
<testsuite name="Unit\Testsuite3" file="/Unit/Testsuite1.php" tests="2" assertions="2" failures="0" errors="0" time="0.003623">
<testcase name="someRandomTestName1" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="8" assertions="1" time="0.002003"/>
<testcase name="someRandomTestName2" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="13" assertions="1" time="0.000795"/>
</testsuite>
<testsuite name="Unit\Testsuite4" file="/Unit/Testsuite1.php" tests="4" assertions="4" failures="0" errors="0" time="0.003623">
<testcase name="someRandomTestName1" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="8" assertions="1" time="0.002003"/>
<testcase name="someRandomTestName2" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="13" assertions="1" time="0.000795"/>
<testcase name="someRandomTestName3" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="16" assertions="1" time="0.000795"/>
<testcase name="someRandomTestName4" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="21" assertions="1" time="0.000795"/>
</testsuite>
</testsuite>
</testsuites>
Merged Result File
<?xml version="1.0" encoding="utf-8"?>
<testsuites>
<testsuite tests="11" assertions="11" failures="0" errors="0" time="3.703701">
<testsuite name="/Some_PHPUnit_Testsuite1" tests="2" assertions="2" failures="0" errors="0" time="1.234567">
<testsuite name="Unit\Testsuite2" file="/Unit/Testsuite1.php" tests="2" assertions="2" failures="0" errors="0" time="0.003623">
<testcase name="someRandomTestName1" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="8" assertions="1" time="0.002003"/>
<testcase name="someRandomTestName2" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="13" assertions="1" time="0.000795"/>
</testsuite>
</testsuite>
<testsuite name="/Some_PHPUnit_Testsuite2" tests="3" assertions="3" failures="0" errors="0" time="1.234567">
<testsuite name="Unit\Testsuite1" file="/Unit/Testsuite1.php" tests="3" assertions="3" failures="0" errors="0" time="0.003623">
<testcase name="someRandomTestName1" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="8" assertions="1" time="0.002003"/>
<testcase name="someRandomTestName2" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="13" assertions="1" time="0.000795"/>
<testcase name="someRandomTestName3" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="18" assertions="1" time="0.000825"/>
</testsuite>
</testsuite>
<testsuite name="/Some_PHPUnit_Testsuite3" tests="6" assertions="6" failures="0" errors="0" time="1.234567">
<testsuite name="Unit\Testsuite3" file="/Unit/Testsuite1.php" tests="2" assertions="2" failures="0" errors="0" time="0.003623">
<testcase name="someRandomTestName1" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="8" assertions="1" time="0.002003"/>
<testcase name="someRandomTestName2" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="13" assertions="1" time="0.000795"/>
</testsuite>
<testsuite name="Unit\Testsuite4" file="/Unit/Testsuite1.php" tests="4" assertions="4" failures="0" errors="0" time="0.003623">
<testcase name="someRandomTestName1" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="8" assertions="1" time="0.002003"/>
<testcase name="someRandomTestName2" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="13" assertions="1" time="0.000795"/>
<testcase name="someRandomTestName3" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="16" assertions="1" time="0.000795"/>
<testcase name="someRandomTestName4" class="Unit\Testsuite1" file="/Unit/Testsuite1.php" line="21" assertions="1" time="0.000795"/>
</testsuite>
</testsuite>
</testsuite>
</testsuites>
Developer
Environment
Boot:
vagrant up
Enter virtual machine:
vagrant ssh
Run tests:
cd /vagrant
vendor/bin/phpunit src/Test/
Build targets
vagrant@andreas-weber:/vagrant$ ant
Buildfile: /vagrant/build.xml
help:
[echo]
[echo] The following commands are available:
[echo]
[echo] | +++ Build +++
[echo] |-- build (Run the build)
[echo] | |-- dependencies (Install dependencies)
[echo] | |-- tests (Lint all files and run tests)
[echo] | |-- metrics (Generate quality metrics)
[echo] |-- cleanup (Cleanup the build directory)
[echo] |
[echo] | +++ Composer +++
[echo] |-- composer -> composer-download, composer-install
[echo] |-- composer-download (Downloads composer.phar to project)
[echo] |-- composer-install (Install all dependencies)
[echo] |
[echo] | +++ Testing +++
[echo] |-- phpunit -> phpunit-full
[echo] |-- phpunit-tests (Run unit tests)
[echo] |-- phpunit-full (Run unit tests and generate code coverage report / logs)
[echo] |
[echo] | +++ Metrics +++
[echo] |-- coverage (Show code coverage metric)
[echo] |-- phploc (Show lines of code metric)
[echo] |-- qa (Run quality assurance tools)
[echo] |-- |-- phpcpd (Show copy paste metric)
[echo] |-- |-- phpcs (Show code sniffer metric)
[echo] |-- |-- phpmd (Show mess detector metric)
[echo] |
[echo] | +++ Metric Reports +++
[echo] |-- phploc-report (Generate lines of code metric report)
[echo] |-- phpcpd-report (Generate copy paste metric report)
[echo] |-- phpcs-report (Generate code sniffer metric report)
[echo] |-- phpmd-report (Generate mess detector metric report)
[echo] |
[echo] | +++ Tools +++
[echo] |-- lint (Lint all php files)
[echo]
Attributions
Thanks to Sebastian Bergmann for his gist merge-phpunit-xml.php, which was the base and inspired me to develop this library.
Thoughts
Pull requests are highly appreciated. Built with love. Hope you'll enjoy.. :-)
99designs/php-junit-merge 适用场景与选型建议
99designs/php-junit-merge 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14.17k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 09 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 99designs/php-junit-merge 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 99designs/php-junit-merge 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 14.17k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-09-08