bokner
Running ExUnit tests from iex shell
Hello everyone,
I’m trying to run ExUnit tests from the shell, and I almost got it working:
iex(2)> ExUnit.start(autorun: false)
:ok
iex(3)> test_file = "test/sample_test.exs"
"test/sample_test.exs"
iex(4)> Mix.Compilers.Test.require_and_run([test_file], ["test"], formatters: [ExUnit.CLIFormatter])
........
Finished in 3.6 seconds
8 tests, 0 failures
{:ok, %{excluded: 0, failures: 0, skipped: 0, total: 8}}
So far so good, but the second run of Mix.Compilers.Test.require_and_run/3 doesn’t seem to do anything:
iex(5)> Mix.Compilers.Test.require_and_run([test_file], ["test"], formatters: [ExUnit.CLIFormatter])
Finished in 0.00 seconds
0 failures
{:ok, %{excluded: 0, failures: 0, skipped: 0, total: 0}}
It looks like the test compiler caches the test results. If that’s the case, can it be forced to invalidate it and run the tests from scratch again?
Most Liked
paulanthonywilson
I wanted to do this because of the apps I’m working in at the moment has a long startup time, making TDD painful. Someone pointed me to a solution based on TestIex — Easier Test Driven Development in Elixir | by Daniel Olshansky | Medium and it works like treat.
4
filipe
basically you have to load it again to rerun the test
Code.load_file(test_file)
or even better compile_file, since load_file is depricated
Code.compile_file(test_file")
then you can rerun
Mix.Compilers.Test.require_and_run([test_file], ["test"], formatters: [ExUnit.CLIFormatter])
2
Popular in Questions
In Ruby, I can go:
User.find_by(email: "foobar@email.com").update(email: "hello@email.com")
How can I do something similar in Elixir? ...
New
can someone please explain to me how Enum.reduce works with maps
New
What is most correct way to open, read and parse JSON file with poison?
For example if we have example.json file in root of some projec...
New
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
To simplify some tasks at work, I wrote and published this package yesterday. It’s a simple macro that enables Access behaviour on struct...
New
In AR this is so simple
@articles = current_user.articles
How to do in Ecto?
def index(conn, _params) do
current_user = conn.assig...
New
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217
Let’s say I have a map with required and optional k...
New
Other popular topics
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
15:22:35.803 [error] gen_event {lager_file_backend...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
I would like to know what is the best IDE for elixir development?
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Hi everyone,
One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
Hey :wave:t3: Elixir community,
I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New







