Problem with rumbrella example

Hi all,

I have followed the Phoenix Programming book closely and am stuck at chapter 13 Testing Channels and OTP.

running the tests gives:

==> info_sys
Compiling 2 files (.ex)
warning: function InfoSys.Test.HTTPClient.request/1 is undefined (module InfoSys.Test.HTTPClient is not available)

From what i understood running mix test will cause test_helper.exs to be called and inside it in calls Code.require_file "backends/http_client.exs", __DIR__ to load the test http client so that InfoSys.Test.HTTPClient.request should work but it doesn’t.

I checked through everything and am lost about what could be wrong. Wonder if there is any kind soul who will spend a bit of time to look at my repo

Do your tests get run?

The message you have shown is just a warning, that the module InfoSys.Test.HTTPClient is not available during compilation of the project. This is totally true, since your test_helper.exs will only be run at run time of the tests, therefore that specific module will only be created and hotloaded after that warning has been printed out.

You can avoid this, by renaming backends/http_client.exs to backends/http_client.ex and also adjusting your :elixirc_paths to contain "test/backend" when run in test-environment. You can see an example of this in rumbls mix.exs.

Do not forget to remove the Code.require_file after doing that change.

1 Like

I see. I thought the warning is the cause of my test failing but it was due to my wolfram.xml file not being complete.

Nevertheless i learn more about how exs work from you. Thanks