Test of KV Server (Getting Started) works manually, not with mix

67 views
Skip to first unread message

bengt e

unread,
Jul 5, 2015, 10:17:47 AM7/5/15
to elixir-l...@googlegroups.com
Greetings

Still learning from Getting Started, I have a test file apps/kv_server/test/kv_server_test.exs with content copied from http://elixir-lang.org/getting-started/mix-otp/docs-tests-and-pipelines.html.
It can be run manually (provided I start "iex -S mix" in another window + modify the file by adding ExUnit.start and comment away :application:start/stop).

Ex:

 elixir kv_server_test.exs
.

Finished in 0.03 seconds (0.03s on load, 0.00s on tests)
1 tests, 0 failures


When I try to use it the mix way (nothing started, no modifications) it does not work:

 mix test apps/kv_server/test/kv_server_test.exs
==> kv


Finished in 0.00 seconds (0.00s on load, 0.00s on tests)
0 tests, 0 failures

Randomized with seed 9016
==> kv_server
Accepting connections on port 4040


Finished in 0.00 seconds
0 tests, 0 failures


What would be a good place to start looking for the problem?

José Valim

unread,
Jul 5, 2015, 10:28:38 AM7/5/15
to elixir-l...@googlegroups.com
Each project will try to run "apps/kv_server/test/kv_server_test.exs" which won't exist.

    mix test test/kv_server_test.exs

Should work as expected. That's the path printed before each test name when they fail.



José Valim
Skype: jv.ptec
Founder and Director of R&D

--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/342c9672-0982-439c-bc39-c38c26fbbecd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

bengt e

unread,
Jul 5, 2015, 12:28:46 PM7/5/15
to elixir-l...@googlegroups.com, jose....@plataformatec.com.br
I must thank you once again for answering very quickly. Unfortuntately I still have problems and hope there is something simple that I have missed.

1) In the beginning there was no failure (now see 3) so I have no path printed. The test case was just not performed.


2) When I change directory (to kv_umbrella/apps/kv_server/) so that test/kv_server_test.exs is present I get the error:

 mix test test/kv_server_test.exs
Compiled lib/kv_server_supervisor.ex
Compiled lib/kv_server_command.ex

== Compilation error on file lib/kv_server.ex ==
** (CompileError) lib/kv_server.ex:28: module Pipe is not loaded and could not be found
    (stdlib) lists.erl:1352: :lists.mapfoldl/3


3) When I use an absolute path (from kv_umbrella/) I get this error:

 mix test `pwd`/apps/kv_server/test/kv_server_test.exs
==> kv

=INFO REPORT==== 5-Jul-2015::18:21:42 ===
    application: kv
    exited: stopped
    type: temporary


  1) test server interaction (KV_server_integration_test)
     /home/eleberg/kv_umbrella/apps/kv_server/test/kv_server_test.exs:18
     ** (MatchError) no match of right hand side value: {:error, :econnrefused}
     stacktrace:
       /home/eleberg/kv_umbrella/apps/kv_server/test/kv_server_test.exs:14: KV_server_integration_test.__ex_unit_setup_1/1
       /home/eleberg/kv_umbrella/apps/kv_server/test/kv_server_test.exs:4: KV_server_integration_test.__ex_unit__/2




Finished in 0.03 seconds (0.03s on load, 0.00s on tests)
1 tests, 1 failures

Randomized with seed 855441

==> kv_server
Accepting connections on port 4040


Finished in 0.00 seconds
0 tests, 0 failures



That sems to me as if the test is run when only KV is started, and not afterwards when KV_server has started. Am I correct?


bengt

José Valim

unread,
Jul 5, 2015, 12:42:41 PM7/5/15
to bengt e, elixir-l...@googlegroups.com
Which Elixir version are you using? There is something wrong with your setup. If you can push your repo to github, I can also take a look later.

--

bengt e

unread,
Jul 5, 2015, 12:57:33 PM7/5/15
to elixir-l...@googlegroups.com, jose....@plataformatec.com.br
 elixir --version
Elixir 1.0.4

Yes, there is something wrong with my setup. I am doing my first Elixir-mix ever. Errors are to be expected.

It would be presumptuous of me to send all of my kv_umbrella/ to you. I will try to learn by finding out more by myself. If it is a simple solution like "remove  _build/", the learning would be too small for it to be worth a long session. But if it is a real problem, like this seems to be, then I think a long session is ok.


bengt

bengt e

unread,
Jul 7, 2015, 2:16:50 PM7/7/15
to elixir-l...@googlegroups.com, jose....@plataformatec.com.br
Greetings,

Just for completeness: I got it to work without changing any file. The correct way to run a particular test file is to start the test from kv_umbrella/ while refering to the test file relative from its app directory.
It is not possible to start from kv_umbrella/apps/kv_server/ where the relaive path makes sense.
It is not not possible to stand in kv_umbrella/ and use the full path to the test file!

If this particular usage is ever in an O'Reilly book it should have a scorpion picture explanation.


bengt
Reply all
Reply to author
Forward
0 new messages