Yonis
How can I control every step of tests running with ExUnit
I’m developing web automation tools using wallaby.
One of the challenges in web automation is that sometimes the tests are failing for no reason and when I run it again it passes.
When I run a set of tests especially when I run it virtual machine I need a way to run a set of tests at one time and run some of them again in case of failure.
Another thing, because I’m using VM to run the tests I need a way to send messages to Slack so I can easily monitor the results.
I’m sending a few kinds of messages: before all the tests are started there is a message that the running start, before and after every test start I’m sending a message that the tests starts/ends and the result (failure/success),
finally, after all the tests completed I need to send a summary of the results.
Right now I’m managing all things with a bash file that gets the list of the tests and runs all of them one by one.
The messages before and after every test I’m sending from ExUnit formatter.
I’m looking for a better solution to manage this system without the bash file by using just the elixir system.
What I’m looking for is a way to run the all tests in one run in the order that I want and to get access to the action before the tests started between them and before they finished.
I would love your help.
THX
Most Liked
eksperimental
I think what you may probably need is to run your tests programmatically.
Read this thread,
ExUnit tests from a module instead of command line/mix
and the implementation of the test task in Mix. (look for the run/1 function)
elixir/lib/mix/lib/mix/tasks/test.ex at main · elixir-lang/elixir · GitHub
eksperimental
More on the subject,
If you are hacking Mix.Tasks.Test
read this article by @dnlserrano
dnlserrano.github.io/_posts/2019-05-26-exunit-deep-dive.markdown at master · dnlserrano/dnlserrano.github.io · GitHub
Also a recent library from @devonestes seem to do something similar.
muzak/lib/muzak/runner.ex at 63166c0a2526cda60787c22127be8645cc13e4dd · devonestes/muzak · GitHub
I haven’t tested it, but this is this looks like the minimum code required in this test in this library.
nimler/test_all.exs at master · wltsmrz/nimler · GitHub
How did I find out all this?
Code search results · GitHub
dimitarvp
You don’t need to do that. You can do this in your mix.exs:
def project do
[
app: :your_app,
version: "1.2.3",
elixir: "~> 1.14.0",
elixirc_paths: elixirc_paths(Mix.env()), # 👈 NOTICE THIS
compilers: [:phoenix] ++ Mix.compilers(),
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps: deps()
]
end
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]
And then put everything that you want to have access to in tests in test/support. I don’t think you should put it in the root test/ directory however.
Popular in Questions
Other popular topics
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
- #code-sync
- #javascript
- #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









