GithubHelp home page GithubHelp logo

kathgironpe / mix-test.watch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lpil/mix-test.watch

0.0 1.0 0.0 121 KB

๐ŸŽ Because TDD is awesome

License: Other

Elixir 99.58% Shell 0.42%

mix-test.watch's Introduction

mix test.watch

Build Status Hex version Hex downloads

Automatically run your Elixir project's tests each time you save a file. Because TDD is awesome.

Usage

Add it to your dependencies:

# mix.exs (Elixir 1.4)
def deps do
  [{:mix_test_watch, "~> 0.8", only: :dev, runtime: false}]
end
# mix.exs (Elixir 1.3 and earlier)
def deps do
  [{:mix_test_watch, "~> 0.8", only: :dev}]
end

Run the mix task

mix test.watch

Start hacking :)

Running Additional Mix Tasks

Through the mix config it is possible to run other mix tasks as well as the test task. For example, if I wished to run the Dogma code style linter after my tests I would do so like this.

# config/config.exs
use Mix.Config

if Mix.env == :dev do
  config :mix_test_watch,
    tasks: [
      "test",
      "dogma",
    ]
end

Tasks are run in the order they appear in the list, and the progression will stop if any command returns a non-zero exit code.

All tasks are run with MIX_ENV set to test.

Passing Arguments To Tasks

Any command line arguments passed to the test.watch task will be passed through to the tasks being run. If I only want to run the tests from one file every time I save a file I could do so with this command:

mix test.watch test/file/to_test.exs

Note that if you have configured more than one task to be run these arguments will be passed to all the tasks run, not just the test command.

Running tests of modules that changed

Elixir 1.3 introduced --stale option that will run only those test files which reference modules that have changed since the last run. You can pass it to test.watch:

mix test.watch --stale

Clearing The Console Before Each Run

If you want mix test.watch to clear the console before each run, you can enable this option in your config/dev.exs as follows:

# config/config.exs
use Mix.Config

if Mix.env == :dev do
  config :mix_test_watch,
    clear: true
end

Excluding files or directories

To ignore changes from specific files or directories just add exclude: regexp patterns to your config in mix.exs:

# config/config.exs
use Mix.Config

if Mix.env == :dev do
  config :mix_test_watch,
    exclude: [~r/db_migration\/.*/,
              ~r/useless_.*\.exs/]
end

The default is exclude: [~r/\.#/, ~r{priv/repo/migrations}].

Compatibility Notes

On Linux you may need to install inotify-tools.

Desktop Notifications

You can enable desktop notifications with ex_unit_notifier.

Licence

mix test.watch
Copyright ยฉ 2015-present Louis Pilfold

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

mix-test.watch's People

Contributors

lpil avatar daveshah avatar msoedov avatar smeevil avatar aeons avatar behe avatar johnhamelink avatar pinfieldharm avatar steffkes avatar adambrodzinski avatar slashdotdash avatar bentruyman avatar bryanjos avatar casio avatar j8th avatar maartenvanvliet avatar kabturek avatar outsmartin avatar rrrene avatar papipo avatar rustamtolipov avatar illiatdesdindes avatar unclesnottie avatar iboss-ptk avatar optikfluffel avatar zeroasterisk avatar

Watchers

James Cloos 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.