Skip to content

Latest commit

 

History

History
55 lines (39 loc) · 1.03 KB

13.4.md

File metadata and controls

55 lines (39 loc) · 1.03 KB

ExUnit: Elixirに添付されているテストフレームワーク

mix new 実行時に生成されたテストのテンプレートが、本に掲載されているコードと違う

defmodule IssuesTest do
  use ExUnit.Case
  doctest Issues

  test "greets the world" do
    assert Issues.hello() == :world
  end
end

テストの実行

$ mix test
goh@goh% mix test


  1) test three values returned if three given (CLITest)
     test/cli_test.exs:12
     Assertion with == failed
     code:  assert parse_args(["user", "project", "99"]) == {"user", "project", 99}
     left:  {"user", "project", "99"}
     right: {"user", "project", 99}
     stacktrace:
       test/cli_test.exs:13: (test)

.....

Finished in 0.05 seconds
2 doctests, 4 tests, 1 failure

Randomized with seed 701314

3つ目の引数を整数に変換して返すように lib/issues/cli.ex を修正

goh@goh% mix test
Compiling 1 file (.ex)
......

Finished in 0.05 seconds
2 doctests, 4 tests, 0 failures

Randomized with seed 998107