Elixir ExUnit: module under test is not available
Asked Answered
L

1

13

I'm following this tutorial: http://elixir-lang.org/getting-started/mix-otp/agent.html

So in my Elixir project I have a module lib/kv/bucket.exs, and a test for it test/kv/bucket_test.exs.

When I'm running mix test, I get the following error: ** (UndefinedFunctionError) undefined function KV.Bucket.start_link/0 (module KV.Bucket is not available) Am I missing something?

Lasala answered 13/3, 2016 at 15:25 Comment(0)
L
16

So it turns out, the module has to use an .ex extension instead of .exs, and you need to run mix compile to compile the new module. After that, mix test is able to find the module and everything works as expected.

Lasala answered 13/3, 2016 at 15:29 Comment(1)
Same error, but my mistake was putting bucket.ex in the test directory instead of the kv/lib/kv/ directory (which I had to create). $ mix test will take care of compiling the lib/ filesSonar

© 2022 - 2024 — McMap. All rights reserved.