iakio / phpunit-smartrunner
仅运行必要测试用例的 CLI 工具。
    0.4.0
    2016-07-26 15:03 UTC
Requires
- php: >=5.4
- ext-xdebug: *
- webmozart/path-util: ^2.2
Requires (Dev)
- behat/behat: ^3.0
- mikey179/vfsstream: ^1.5
- phpunit/phpunit: >=4.6,<5.4
This package is not auto-updated.
Last update: 2024-09-10 03:48:45 UTC
README
smartrunner 通过使用 phpdbg 或 xdebug 的代码覆盖率数据,通过代码解决 SUT(系统 Under Test)和测试用例之间的依赖关系。
- 当使用参数 CalcTest.php调用smartrunner时,它会运行CalcTest.php测试用例。
- 当使用参数 Calc.php调用smartrunner时,它也会运行CalcTest.php。此外,它可能还会运行与Calc.php相关的所有测试用例。
安装
$ composer require --dev iakio/phpunit-smartrunner:dev-master
使用方法
$ vendor/bin/smartrunner init
这会创建 .smartrunner/phpunit.xml.dist 文件。如果您已经有一些测试代码,并且想要确保存储 SUT 和测试之间的所有依赖关系,可以使用此文件运行 PHPUnit。
$ vendor/bin/phpunit -c .smartrunner/phpunit.xml.dist tests
然后,从您喜欢的 IDE、编辑器或文件系统监视器运行 smartrunner。
$ vendor/bin/smartrunner run src/Calc.php
设置示例
gomon
> gomon -m=\.php$ -R -F -- vendor\bin\smartrunner run
watchy
$ watchy -w . -- bash -c 'vendor/bin/smartrunner run $FILE'
or
> watchy -w . -- cmd /C "vendor\bin\smartrunner run %FILE%"
grunt
module.exports = function (grunt) {
    grunt.initConfig({
        shell: {
            smartrunner: {
                file: "",
                command: function () {
                    return "vendor/bin/smartrunner run " +
                        grunt.config.get('shell.smartrunner.file');
                }
            }
        },
        esteWatch: {
            options: {
                dirs: [
                    'src/**/',
                    'tests/**/',
                ]
            },
            php: function (filePath) {
                grunt.config("shell.smartrunner.file", filePath);
                return ['shell:smartrunner'];
            },
        },
    });
    grunt.loadNpmTasks('grunt-este-watch');
    grunt.loadNpmTasks('grunt-shell');
};
配置
如果您想使用 phpunit.phar,请修改您的 .smartrunner/config.php
<?php
return function ($config) {
    $config["phpunit"] = "php phpunit.phar";
    $config["ignore"] = [
        "vendor\/**\/*"
    ];
};
要求
- php >= 5.4
- phpdbg 或 xdebug
许可证
本软件在 MIT 许可证下发布。