定制 vektah/phpunit-parallel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vektah/phpunit-parallel

最新稳定版本:1.5.3

Composer 安装命令:

composer require --dev vektah/phpunit-parallel

包简介

Concurrent Test Executor for PHPUnit

README 文档

README

Another Concurrent Test Executor for PHPUnit

I'm no longer maintaining this project, it is here as an archive only.

For an alternative, check out fasttest

How does it work?

phpunit-parallel uses react-php based even loop to talk to a number of worker processes. It communicates with these processes over a unix pipe (fd=3). STDOUT is passed through and STDERR causes tests to error. If a process dies you will know which test was running on that process when it dies.

Get it!

Add into your projects composer.json

    "require-dev": {
        "vektah/phpunit-parallel": "~1.0"
    },

and composer update vektah/phpunit-parallel

Run it!

By default no options are needed, phpunit-parallel will pick up your phpunit.xml and find your tests. Simply run:

./vendor/bin/phpunit-parallel

If your config is in a weird place -c path/to/phpunit.xml should fix it.

You can also specify a list of test files to run:

./vendor/bin/phpunit-parallel src/tests/AllTheThingsTest.php

Still lost? Get help!

./vendor/bin/phpunit-parallel --help

Format it!

The default lane formatter looks like this when running paratests own test suite.

phpunit-parallel % ./bin/phpunit-parallel
| | |✓| | |   1%      0ms    0.0MB  DataProviderTest::testNothing with data set #2
... snip ...
| | |✓| | |  78%      0ms    0.0MB  DataProviderTest::testNothing with data set #69
| | | |✓| |  79%     11ms    0.5MB  WorkerTestExecutorTest::testStartTestSendsNextTest
| | |✓| | |  80%      6ms    0.5MB  WorkerTestExecutorTest::testStdErrWhileExecutingTestSendsOnlyOneResult
|✓| | | | |  81%     10ms    0.6MB  WorkerTestExecutorTest::testCompletingTestSendsResultToDistributor
|✓| | | | |  82%      0ms    0.1MB  WorkerTestExecutorTest::testProcessSendsUnexpectedResult
| | |✓| | |  83%      1ms    0.1MB  WorkerTestExecutorTest::testProcessCrashWithoutStderr
| | | |✓| |  84%      1ms    0.1MB  WorkerTestExecutorTest::testProcessCrashWithActiveTest
|✓| | | | |  85%      2ms    0.2MB  TestRequestTest::testEncodeDecode
| | | |✓| |  86%      0ms    0.0MB  TestResultTest::testCreateFromRequest
| | |✓| | |  87%      3ms    0.2MB  TestResultTest::testEncodeDecode
|✓| | | | |  89%      0ms    0.1MB  BufferedReaderTest::testWaitingLines
|✓| | | | |  90%      0ms    0.0MB  BufferedReaderTest::testMultipleCallsForOneLineWaiting
| | | |✓| |  91%      2ms    0.1MB  BufferedReaderTest::testPendingPromises
| | |✓| | |  92%      2ms    0.1MB  BufferedReaderTest::testMixedWaitingAndPromises
|✓| | | | |  93%      0ms    0.1MB  BufferedReaderTest::testMultipleCallsForOneLinePending
| | | |✓| |  94%      0ms    0.0MB  BufferedReaderTest::testMultipleLinesInOneCallWaiting
|✓| | | | |  95%      0ms    0.0MB  BufferedReaderTest::testMultipleLinesSplitAcrossWaitingPending
| | |✓| | |  96%      0ms    0.0MB  BufferedReaderTest::testMultipleLinesInOneCallPending
| | | |✓| |  97%      0ms    0.0MB  BufferedReaderTest::testPendingThenWaiting
| | | | |✓|  98%   1000ms    0.0MB  SleepTest::testSleeps with data set #0
| |✓| | | | 100%   1000ms    0.0MB  SleepTest::testSleeps with data set #1
-----------


Time: 1.31 seconds, Memory: 4.62Mb

OK (91 tests)
Most expensive tests by memory usage are:
   0.6MB WorkerTestExecutorTest::testCompletingTestSendsResultToDistributor
   0.5MB WorkerTestExecutorTest::testStdErrWhileExecutingTestSendsOnlyOneResult
   0.5MB WorkerTestExecutorTest::testStartTestSendsNextTest
   0.2MB TestResultTest::testEncodeDecode
   0.2MB TestRequestTest::testEncodeDecode

Most expensive tests by duration are:
  1000ms SleepTest::testSleeps with data set #1
  1000ms SleepTest::testSleeps with data set #0
    11ms WorkerTestExecutorTest::testStartTestSendsNextTest
    10ms WorkerTestExecutorTest::testCompletingTestSendsResultToDistributor
     6ms WorkerTestExecutorTest::testStdErrWhileExecutingTestSendsOnlyOneResult

What is this madness? It draws a vertical lane for each worker, and on completion of a test it marks the result in that workers column. This can be useful if a test is modifying global/static state and causes another test to break. See a failure? Look up the lane and see which tests ran before.

There is also xunit for phpunit style output:

phpunit-parallel % ./bin/phpunit-parallel --formatter xunit
PHPUnit Parallel 1.0.0

...............................................................   63 /    91 ( 69%)
............................

Time: 1.31 seconds, Memory: 4.62Mb

OK (91 tests)
Most expensive tests by memory usage are:
   0.6MB WorkerTestExecutorTest::testCompletingTestSendsResultToDistributor
   0.5MB WorkerTestExecutorTest::testStdErrWhileExecutingTestSendsOnlyOneResult
   0.5MB WorkerTestExecutorTest::testStartTestSendsNextTest
   0.2MB TestResultTest::testEncodeDecode
   0.2MB TestRequestTest::testEncodeDecode

Most expensive tests by duration are:
  1000ms SleepTest::testSleeps with data set #0
  1000ms SleepTest::testSleeps with data set #1
    10ms WorkerTestExecutorTest::testStdErrWhileExecutingTestSendsOnlyOneResult
    10ms WorkerTestExecutorTest::testStartTestSendsNextTest
     7ms WorkerTestExecutorTest::testCompletingTestSendsResultToDistributor

or tap

phpunit-parallel % ./bin/phpunit-parallel --formatter tap
TAP version 13
1..91
ok 1 - phpunit_parallel\dummy\DataProviderTest::testNothing with data set #0
... snip ...
ok 67 - phpunit_parallel\dummy\DataProviderTest::testNothing with data set #66
 ok 71 - phpunit_parallel\dummy\OutputTest::testEcho
ok 74 - phpunit_parallel\ipc\WorkerTestExecutorTest\WorkerTestExecutorTest::testStartTestSendsNextTest
ok 75 - phpunit_parallel\ipc\WorkerTestExecutorTest\WorkerTestExecutorTest::testCompletingTestSendsResultToDistributor
ok 76 - phpunit_parallel\ipc\WorkerTestExecutorTest\WorkerTestExecutorTest::testStdErrWhileExecutingTestSendsOnlyOneResult
ok 77 - phpunit_parallel\ipc\WorkerTestExecutorTest\WorkerTestExecutorTest::testProcessCrashWithActiveTest
ok 78 - phpunit_parallel\ipc\WorkerTestExecutorTest\WorkerTestExecutorTest::testProcessCrashWithoutStderr
ok 79 - phpunit_parallel\ipc\WorkerTestExecutorTest\WorkerTestExecutorTest::testProcessSendsUnexpectedResult
ok 80 - phpunit_parallel\model\TestRequestTest::testEncodeDecode
ok 81 - phpunit_parallel\model\TestResultTest::testEncodeDecode
ok 82 - phpunit_parallel\model\TestResultTest::testCreateFromRequest
ok 84 - phpunit_parallel\stream\BufferedReaderTest::testPendingPromises
ok 83 - phpunit_parallel\stream\BufferedReaderTest::testWaitingLines
ok 86 - phpunit_parallel\stream\BufferedReaderTest::testMultipleCallsForOneLineWaiting
ok 85 - phpunit_parallel\stream\BufferedReaderTest::testMixedWaitingAndPromises
ok 87 - phpunit_parallel\stream\BufferedReaderTest::testMultipleCallsForOneLinePending
ok 88 - phpunit_parallel\stream\BufferedReaderTest::testMultipleLinesInOneCallWaiting
ok 91 - phpunit_parallel\stream\BufferedReaderTest::testPendingThenWaiting
ok 90 - phpunit_parallel\stream\BufferedReaderTest::testMultipleLinesSplitAcrossWaitingPending
ok 89 - phpunit_parallel\stream\BufferedReaderTest::testMultipleLinesInOneCallPending
ok 72 - phpunit_parallel\dummy\SleepTest::testSleeps with data set #0
ok 73 - phpunit_parallel\dummy\SleepTest::testSleeps with data set #1

vektah/phpunit-parallel 适用场景与选型建议

vektah/phpunit-parallel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 25.61k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2015 年 03 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「testing」 「phpunit」 「ci」 「parallel」 「concurrent」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 vektah/phpunit-parallel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 vektah/phpunit-parallel 我们能提供哪些服务?
定制开发 / 二次开发

基于 vektah/phpunit-parallel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 25.61k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-03-02