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
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
Hi,
is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
Hi there, I'm working through my first release with elixir/phoenix. I've built a release with distillery and found that it crashes when I...
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
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
Hi all,
I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I'm trying to use Postg...
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
Hi all
I want to have a unix time, from the current time plus 1 hour.
DateTime.now + 1 hour
How to get it in elixir?
Thanks
New
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work.
Or rather, not char, but a substr...
New
Other popular topics
Manning 2016 Halloween weekend sale via Deal of the Day
Friday, October 28 - Half off all MEAPs - code WM102816LT
Saturday, October 29 ...
New
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
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
I would like to know what is the best IDE for elixir development?
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New







