Last active
January 6, 2016 20:35
-
-
Save emschwar/1b397d7bc5d2e282e5b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule GenServerTestTest do | |
use ExUnit.Case | |
doctest GenServerTest | |
setup do | |
IO.puts "setup starting" | |
{ :ok, pid } = GenServerTest.start_link() | |
IO.puts "setup started" | |
on_exit fn -> | |
IO.puts "on_exit, stopping" | |
GenServerTest.stop() | |
IO.puts "on_exit, stopped" | |
end | |
{ :ok, [pid: pid] } | |
end | |
test "the truth" do | |
IO.puts "test starting" | |
assert 1 + 1 == 2 | |
IO.puts "test stopping" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule GenServerTest do | |
use GenServer | |
def start_link() do | |
IO.puts "gen_server start_link" | |
result = GenServer.start_link(__MODULE__, [], []) | |
IO.puts "gen_server started" | |
result | |
end | |
def stop() do | |
IO.puts "gen_server stop" | |
result = GenServer.stop(__MODULE__) | |
IO.puts "gen_server stopped" | |
result | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/tmp/gen_server_test$ mix test | |
setup starting | |
gen_server start_link | |
gen_server started | |
setup started | |
test starting | |
test stopping | |
on_exit, stopping | |
gen_server stop | |
1) test the truth (GenServerTestTest) | |
test/gen_server_test_test.exs:19 | |
** (exit) no process | |
stacktrace: | |
(stdlib) gen.erl:260: :gen.do_for_proc/2 | |
(gen_server_test) lib/gen_server_test.ex:13: GenServerTest.stop/0 | |
test/gen_server_test_test.exs:12: anonymous fn/0 in GenServerTestTest.__ex_unit_setup_0/1 | |
(ex_unit) lib/ex_unit/on_exit_handler.ex:82: ExUnit.OnExitHandler.exec_callback/1 | |
(ex_unit) lib/ex_unit/on_exit_handler.ex:66: ExUnit.OnExitHandler.on_exit_runner_loop/0 | |
Finished in 0.05 seconds (0.05s on load, 0.00s on tests) | |
1 test, 1 failure | |
Randomized with seed 601203 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment