Git Product home page Git Product logo

guard-phpunit's Introduction

Guard::PHPUnit Build Status Dependency Status

Guard-phpunit allows you to automatically run PHPUnit tests when sources are modified. It helps with integrating test-driven development (TDD) into your development process: Just launch guard-phpunit before you start working and it will notify you about the status of your tests!

Note: Although guard-phpunit should work with any PHP version PHPUnit supports, it has only been tested on PHP 5.3.8 and 5.4.4.

Install

Please be sure to have PHP, PHPUnit and Ruby installed on your machine before you proceed with the installation.

The latest versions of Ruby come with a packages-manager called gem. gem can be used to install various packages, including guard-phpunit.

To install guard-phpunit, run the following command in the terminal:

$ gem install guard-phpunit

Usage

Please read the Guard usage documentation.

Guardfile

Guard-phpunit can be used with any kind of PHP projects that uses PHPUnit as its testing framwork. Please read the Guard documentation for more information about the Guardfile DSL.

By default, guard-phpunit will use the current working directory (pwd) to search for tests and run them on start (if you enabled the :all_on_start option).

Example PHP project

The PHPUnit documentaion uses the Object Freezer library as an example on how to organize tests. This project uses the Tests directory for its tests.

An example of the Guardfile for the same project would look something like:

guard 'phpunit', :tests_path => 'Tests', :cli => '--colors' do
  # Watch tests files
  watch(%r{^.+Test\.php$})

  # Watch library files and run their tests
  watch(%r{^Object/(.+)\.php}) { |m| "Tests/#{m[1]}Test.php" }
end

Options

The following options can be passed to Guard::PHPUnit:

:all_on_start => false        # Run all tests on startup.
                              # default: true

:all_after_pass => false      # Run all tests after changed tests pass. This ensures
                              # that the process of making changed tests pass didn't
                              # break something else.
                              # default: true

:keep_failed => false         # Remember failed tests and keep running them with
                              # each change until they pass.
                              # default: true

:tests_path => 'tests'        # Relative path to the tests directory. This path
                              # is used when running all the tests.
                              # default: the current working directory (pwd)

:cli => '--colors'            # The options passed to the phpunit command
                              # when running the tests.
                              # default: nil

Development

Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change you make.

Author

Maher Sallam

guard-phpunit's People

Contributors

maher4ever avatar

Watchers

Sasha Gerrand avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.