PHPackages                             iakio/phpunit-smartrunner - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. iakio/phpunit-smartrunner

ActiveLibrary[Testing &amp; Quality](/categories/testing)

iakio/phpunit-smartrunner
=========================

CLI tool that runs only necessary TestCases.

0.4.0(9y ago)1129MITPHPPHP &gt;=5.4

Since Oct 10Pushed 9y ago1 watchersCompare

[ Source](https://github.com/iakio/phpunit-smartrunner)[ Packagist](https://packagist.org/packages/iakio/phpunit-smartrunner)[ RSS](/packages/iakio-phpunit-smartrunner/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (4)Versions (6)Used By (0)

phpunit-smartrunner
===================

[](#phpunit-smartrunner)

[![Build Status](https://camo.githubusercontent.com/bec6678a46c628f3a5044a923e27905405de5dbedb1e6ca6920783faa21a2f60/68747470733a2f2f7472617669732d63692e6f72672f69616b696f2f706870756e69742d736d61727472756e6e65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/iakio/phpunit-smartrunner)

`smartrunner` resolves dependencies between SUTs and test cases by code coverage data using phpdbg or xdebug.

- When `smartrunner` is invoked with an argument `CalcTest.php`, it runs `CalcTest.php` test case.
- When `smartrunner` is invoked with an argument `Calc.php`, it also runs `CalcTest.php`. Additionally, it may run all test cases related to `Calc.php`.

Install
=======

[](#install)

```
$ composer require --dev iakio/phpunit-smartrunner:dev-master

```

Usage
=====

[](#usage)

```
$ vendor/bin/smartrunner init

```

This creates `.smartrunner/phpunit.xml.dist` file. If you already have some test codes, and you want to store all dependencies between SUTs and tests certainly, you can run phpunit with this file.

```
$ vendor/bin/phpunit -c .smartrunner/phpunit.xml.dist tests

```

Then, run smartrunner from your favorite IDE, editor or filesystem watcher.

```
$ vendor/bin/smartrunner run src/Calc.php

```

Setting Examples
================

[](#setting-examples)

[gomon](https://github.com/c9s/gomon)
-------------------------------------

[](#gomon)

```
> gomon -m=\.php$ -R -F -- vendor\bin\smartrunner run

```

[watchy](https://www.npmjs.com/package/watchy)
----------------------------------------------

[](#watchy)

```
$ watchy -w . -- bash -c 'vendor/bin/smartrunner run $FILE'
or
> watchy -w . -- cmd /C "vendor\bin\smartrunner run %FILE%"

```

[grunt](http://gruntjs.com/)
----------------------------

[](#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');
};

```

Configuration
=============

[](#configuration)

If you want to use `phpunit.phar`, change your `.smartrunner/config.php`:

```
