Running tests several times with several configurations

61 views
Skip to first unread message

Jorge Díaz

unread,
May 17, 2016, 10:11:12 PM5/17/16
to elixir-lang-talk
Hi everyone,

Let's say I'm building a SDK for a certain XML-based protocol which can be consumed from several providers and I really need to do my integration testing to check with several of them and not only one. This means I need to hit several hosts and build expectations based on getting a valid responses form them. I know it's a bit unusual integration testing pattern but the whole point here about having an SDK is to provide isolation of the multiple issues with each of them (i.e. SOAP vs. non-SOAP).

I would like to cover this scenario while doing a proper use of ExUnit. Is it possible to launch a set of tests several times each of them loading a different config using Mix.Config from a file?

I'm quite new to Elixir so any clue at any level is welcome. :)

Cheers!
Jorge

José Valim

unread,
May 18, 2016, 3:31:09 AM5/18/16
to elixir-l...@googlegroups.com
The simplest option is to have different test files in your project, each of them using a different configuration that you specify during setup.

A more complex alternative is to have multiple test environments. MIX_ENV=test_foo, MIX_ENV=test_bar and so on. And then specify config/test_foo.exs, config/test_bar.exs and so on. That's what Ecto uses to test multiple adapters/databases. The only issue is that Elixir will compile your project per environment but you can set that to false as build_per_environment: false in your mix.exs.

There are probably many options between those two, it is hard to say which one works better without more details.




José Valim
Skype: jv.ptec
Founder and Director of R&D

--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/170c2cd9-c0f7-49ca-8f1e-14c965410fe7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages