I trying to use a helper for a task in a testing. My folder structure is like this:
config/
lib/
test/
test/test_helper.exs
test/provider_test/(the test files are here)
And now what I want to do is this
config/
lib/
test/
test/test_helper.exs
test/provider_test/(the test files are here)
test/provider_test/helpers/(the helpers files... more or less, one for helper)
I tried to use this (inside a test):
HelperModuler.calling_function(args)
But I get this error:
(UndefinedFunctionError) undefined function HelperModuler.calling_function/1 (module HelperModuler is not available)
To make a module available in all tests, you need to do 2 things:
.ex
.elixirc_paths
key of the value return from MyApp.Mixfile.project/0
in mix.exs
.For example, here's how Phoenix handles adding test/support
for just the :test
Mix env in mix.exs
:
def project do
[...,
elixirc_paths: elixirc_paths(Mix.env),
...]
end
# Specifies which paths to compile per environment.
defp elixirc_paths(:test), do: ["lib", "web", "test/support"]
defp elixirc_paths(_), do: ["lib", "web"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With