Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing test code in elixir unit test

I'm writing tests of some Elixir code that interacts with SSH. In my tests, I'd like to start an SSH server that I can run my code against. I'd prefer to store this code in it's own file in the test directory, and have it imported by various different tests.

I've not been able to get this to work too well though.

I've tried creating an test/ssh_server.ex file containing a SSHServer module, but when I add import SSHServer to my tests, I get:

(CompileError) test/end_to_end_test.exs:13: module SSHServer is not loaded and could not be found

Am I missing something? Is there some way to force mix test to import my test/ssh_server.ex file?

like image 237
obmarg Avatar asked Jun 04 '15 19:06

obmarg


1 Answers

I've currently got around this by manually loading the code from my test_helper.exs file:

Code.load_file("test/ssh_server.ex")
like image 92
obmarg Avatar answered Oct 02 '22 10:10

obmarg