KazuCocoa / ex_parameterized

This library support parameterized test with test_with_params macro.
https://github.com/KazuCocoa/ex_parameterized
MIT License
29 stars 7 forks source link

Does not work with `nil` tuples #32

Closed sobolevn closed 5 years ago

sobolevn commented 5 years ago

I have this very simple test case:

Code

defmodule KiraTest.ExampleTest do
  use ExUnit.Case
  use ExUnit.Parameterized

  describe "nil example" do
    test_with_params "should be working, but does not work",
    fn (first, second) ->
      assert first == second
    end do
      [
        {1, 1},
        {2, 2}
      ]
    end
  end
end

And it works fine.

Now, let's add one more case {nil, nil}:

defmodule KiraTest.ExampleTest do
  use ExUnit.Case
  use ExUnit.Parameterized

  describe "nil example" do
    test_with_params "should be working, but does not work",
    fn (first, second) ->
      assert first == second
    end do
      [
        {1, 1},
        {2, 2},
        {nil, nil}
      ]
    end
  end
end

Output

» mix test

== Compilation error in file test/kira/usecases/example_test.exs ==
** (ArgumentError) argument error
    :erlang.tuple_to_list(nil)
    (ex_parameterized) lib/ex_parameterized/params.ex:92: ExUnit.Parameterized.Params.escape_values/1
    (ex_parameterized) lib/ex_parameterized/params.ex:58: ExUnit.Parameterized.Params.test_with/3
    (elixir) lib/enum.ex:1327: Enum."-map/2-lists^map/1-0-"/2
    (elixir) lib/enum.ex:1327: Enum."-map/2-lists^map/1-0-"/2
    (ex_parameterized) expanding macro: ExUnit.Parameterized.Params.test_with_params/3
    test/kira/usecases/example_test.exs:6: KiraTest.ExampleTest (module)
    (ex_unit) expanding macro: ExUnit.Case.describe/2
    test/kira/usecases/example_test.exs:5: KiraTest.ExampleTest (module)
    (elixir) lib/code.ex:767: Code.require_file/2
    (elixir) lib/kernel/parallel_compiler.ex:211: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6

Version information

I am using:

» mix --version
Erlang/OTP 21 [erts-10.2.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1][hipe] [dtrace]

Mix 1.8.1 (compiled with Erlang/OTP 21)

And {:ex_parameterized, "~> 1.3.5", only: :test},

KazuCocoa commented 5 years ago

I've published https://hex.pm/packages/ex_parameterized/1.3.6 Could you get the latest one? @sobolevn