pajawa

pajawa

ExUnit: Expected behaviour with :group + :async true + :parameterize?

I am trying to run a parameterize’d test with both a :group set and async: true.

The ExUnit docs state: “If both :async and :parameterize are given, the different parameters run concurrently”.

I would expect this to still apply even if a :group is supplied, however, it appears that all parameterized tests use the same group, and they end up running serially.

e.g.

defmodule ParamAsyncGroupTest do
  use ExUnit.Case,
    group: :some_group,
    async: true,
    parameterize: [%{param: :a}, %{param: :b}, %{param: :c}, %{param: :d}]

  test "testing with param", ctx do
    IO.inspect("Testing param: #{ctx.param}")
    Process.sleep(5_000)
    assert true
  end
end
% mix test 
Running ExUnit with seed: 856650, max_cases: 16

"Testing param: d"
."Testing param: c"
."Testing param: b"
."Testing param: a"
.
Finished in 20.0 seconds (20.0s async, 0.00s sync)
4 tests, 0 failures

If I remove the :group then the tests run in parallel:

defmodule ParamAsyncGroupTest do
  use ExUnit.Case,
    # group: :some_group,
    async: true,
    parameterize: [%{param: :a}, %{param: :b}, %{param: :c}, %{param: :d}]

  test "testing with param", ctx do
    IO.inspect("Testing param: #{ctx.param}")
    Process.sleep(5_000)
    assert true
  end
end
%  mix test 
Running ExUnit with seed: 162988, max_cases: 16

"Testing param: d"
"Testing param: c"
"Testing param: a"
"Testing param: b"
....
Finished in 5.0 seconds (5.0s async, 0.00s sync)
4 tests, 0 failures

Thoughts on this?

Most Liked

ausimian

ausimian

The documentation states “tests in the same group never run concurrently”.

Where Next?

Popular in Questions Top

hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New

Other popular topics Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New

We're in Beta

About us Mission Statement