99designs / php-junit-merge
PHP-Unit J-Unit XML 文件合并工具
v1.0.0
2023-09-08 00:54 UTC
Requires
- php: >=5.6
- symfony/console: ^3.0 || ^4.0 || ^5.0
- symfony/finder: ^3.0 || ^4.0 || ^5.0
- theseer/fdomdocument: 1.6.*
Requires (Dev)
- phploc/phploc: 4.*
- phpmd/phpmd: 2.*
- phpunit/phpunit: ^5.0
- sebastian/phpcpd: 2.0.*
- squizlabs/php_codesniffer: 1.5.*
This package is auto-updated.
Last update: 2024-09-08 03:06:12 UTC
README
php-junit-merge 是一个库,用于合并多个.junit结果XML文件。
安装
如果您使用Composer来管理项目的依赖关系,只需在项目的composer.json
文件中添加对andreas-weber/php-junit-merge
的依赖即可。
用法
通过Composer更新依赖关系后,将可用新的二进制文件php-junit-merge
。
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
该二进制文件期望至少两个参数
dir
是应用程序应搜索xml文件的目录file
是要写入合并内容的结果文件
一个简单的调用可能如下所示
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'.
示例
单个结果文件
<?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>
合并结果文件
<?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>
开发者
环境
启动
vagrant up
进入虚拟机
vagrant ssh
运行测试
cd /vagrant
vendor/bin/phpunit src/Test/
构建目标
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]
归属
感谢 Sebastian Bergmann 的gist merge-phpunit-xml.php,这是我开发这个库的基础和灵感来源。
想法
非常欢迎拉取请求。用爱构建。希望你会喜欢.. :-)