Welcome @stefannovak !
You said you were new (if you know this already, hopefully other folks that don’t can benefit from this), so I’ll link you to some interesting things that help a ton when running tests from an operational side.
As you said, not all tests are equal. Sometimes you have third party stuff that you need creds for, sometimes you have great tests that test a bunch of things together but it’s slow (and if THAT test fails, things are bad
) In these cases, it’s good to leverage the mix test
options (which I find absolutely excellent) coupled with tags
(called filters) in the test files.
Here is a link to the options: mix test — Mix v1.17.2.
In order to use those well, you should know about tags
and filters and you can use them both modules and also tests.
Here is where tags
are talked about: ExUnit.Case — ExUnit v1.18.0-dev
Here is a link to some filter usage: mix test — Mix v1.17.2
In a short example, you could do something like this (excerpt from ExUnit.Case — ExUnit v1.18.0-dev):
defmodule ApiTest do
use ExUnit.Case
@moduletag :external
# rest of module with tests
end
And then, you can run/skip the above with the following:
mix test include --external
mix test exclude --external
mix test only --external
Maybe you have a use case like this where you may not want to run all slow tests by default for some reason, you want fast feedback and you have known slow tests (check out --slowest
to find them
)
defmodule MyApp.SomeTest do
use ExUnit.Case
@tag :slow
test "everything works as expected" do
# set up a BUNCH of data to make sure different domains work as expected in unison
end
end
You can configure defaults for tests to be run in test_helper.exs
, like done here: avalanche/test/test_helper.exs at main · HGInsights/avalanche · GitHub, you can exclude the slow
ones if you’d like.
Here is an example of usual steps to do when you have those integration tests: GitHub - HGInsights/avalanche: Avalanche is an Elixir Snowflake Connector built on top of the Snowflake SQL API v2..
Maybe you can add an example module to mix test — Mix v1.17.2? I don’t see an example of setting this up to discuss the filters, so I think that would be helpful in the docs. Doc improvements are always welcome and a great way to get going in the community. The maintainers are incredible. You mentioned you came from C#, so maybe that’s a different change in mindset as well since in the Elixir community (at least how I see it), if you can help, do it! :). Please reach out to me if you need help creating a PR for the docs.
At some point, you’ll get in a situation where you want to run tests but don’t want to set up the external api keys and such. Give this a read when that happens: Mocks and explicit contracts - Dashbit Blog and know that Mox is
. Mostly, because of the concept of boundaries
. Craft your boundaries well and your tests (and Mox) will just work TM 
Hopefully this helps you a little! Welcome to the community!