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 https://olshansky.medium.com/testiex-easier-test-driven-development-in-elixir-761cd1a9f11 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
I have an umbrella app.
Some of the apps inside depend on other apps in the umbrella, unsurprisingly.
I’m writing a test for one of the...
New
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
Hello, how can I check the Phoenix version ?
Thanks !
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone.
What strikes me is th...
New
lets say i have a sample like
a = 20; b = 10;
if (a > b) do
{:ok, "a"}
end
if (a < b) do
{:ok, b}
end
if (a == b) do
{:ok, "equa...
New
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
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
Other popular topics
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch.
This project took far...
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
Hello all!
I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
lets say i have a sample like
a = 20; b = 10;
if (a > b) do
{:ok, "a"}
end
if (a < b) do
{:ok, b}
end
if (a == b) do
{:ok, "equa...
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
Hello guys,
I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
New
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
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
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #javascript
- #code-sync
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








