Skip to content

Instantly share code, notes, and snippets.

@codyjroberts
Created December 15, 2016 17:52
Show Gist options
  • Save codyjroberts/6c32dd6616adf43464352aaa0ffceb34 to your computer and use it in GitHub Desktop.
Save codyjroberts/6c32dd6616adf43464352aaa0ffceb34 to your computer and use it in GitHub Desktop.
IEx Test Helper
defmodule TestHelper do
@moduledoc """
Reloads files and run's ExUnit tests in current directory
Note: Use of this helper may cause issues with state from
previous runs. A possible solution to this may lie in
spawn/1, Task, or IEx.Helpers.respawn/1
"""
def run_tests do
Code.unload_files(Code.loaded_files)
Path.wildcard("*_test.exs")
|> Enum.map(& Code.load_file &1)
ExUnit.Server.cases_loaded
ExUnit.run
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment