I’m going through the “Elixir For Programmers” course by Dave Thomas, which uses a simple game as didactic example.
I have written some unit tests for the game, extracted a TestPlayer module with some helper functions, and figured out I could have it loaded by placing it in test_helper.exs
(placing it in its own file test_player.ex
was like not having written it). Later I discovered that ElixirLS (with VSCode) seemed to ignore the contents of test_helper.exs
: jump to definition doesn’t work.
I decided to try to extract the module again in its own file to se if it was going to make ElixirLS happier: test/test_helper/test_player.exs
first but file compilation failed, then changed to .ex
and still didn’t work.
So I wonder if I can define helper modules in their own files somewhere under the test
folder and, ideally, have them loaded both when testing and by ElixirLS?
I can imagine projects where test-helpers would make test_helper.exs
very large if that’s the only place where they can be defined,
Skimming through three books: Elixir in Action, Programming Elixir 1.6, Testing Elixir; didn’t answer my question.
On Testing Elixir at p.41 I found a test-double defined in integration_tests/soggy_waffle/fake_weather_api.ex
; but that integration_tests
folder seems non-Mix compliant, it leaves me wondering where they’d actually put it in a project, anyway my .ex
file placed under the test
folder were ignored.