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

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
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
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Fl4m3Ph03n1x
Background Let’s assume I have a typical GenServer that receives messages as requests, does some operation in a DB and returns responses....
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
idi527
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir iex(2)...
New

Other popular topics Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New

We're in Beta

About us Mission Statement