ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - lpil/mix-test.watch: 🎠 Because TDD is awesome
🎠   Because TDD is awesome. Contribute to lpil/mix-test.watch development by creating an account on GitHub.
Visit Site

GitHub - lpil/mix-test.watch: 🎠   Because TDD is awesome

GitHub - lpil/mix-test.watch: 🎠 Because TDD is awesome

mix test.watch

Build Status Module Version Hex Docs Total Download License Last Updated

Automatically run your Elixir project's tests each time you save a file.

Because Test-driven development (TDD) is awesome.

Usage

Add it to your dependencies:

For Elixir 1.4 onwards:

# mix.exs
def deps do
  [
    {:mix_test_watch, "~> 1.0", only: [:dev, :test], runtime: false}
  ]
end

For Elixir 1.3 and earlier:

# mix.exs
def deps do
  [
    {:mix_test_watch, "~> 1.0", only: [:dev, :test]}
  ]
end

Optionally, add preferred_cli_env: ["test.watch": :test] for running mix test.watch in :test env by default. It prevents the task from running :dev env config scripts.

# mix.exs
def project do
  [
    ...
    preferred_cli_env: [
      "test.watch": :test
    ],
    ...
  ]
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 Credo code analysis tool 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",
      "credo",
    ]
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 config/config.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}].

Watching files with other extensions

To watch files with extensions other than the default (.erl, .ex, .exs, .eex, .leex, .heex, .xrl, .yrl, .hrl) add them to extra_extensions: in your config:

# config/config.exs
use Mix.Config

if Mix.env == :dev do
  config :mix_test_watch,
    extra_extensions: [".rs"]
end

Compatibility Notes

On Linux you may need to install inotify-tools.

Desktop Notifications

You can enable desktop notifications with ex_unit_notifier.

Alternatives

mix_test_interactive is based on mix test.watch but adds an interactive mode that allows you to dynamically change which tests to run.

Copyright and Licence

mix test.watch

Copyright © 2015 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.

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory