Default value for ExUnit.Case async

I always thought that the default value for ExUnit.Case, async was true. However in a recent video from ElixirCasts the author states otherwise:

Am I mistaken?
Do I need to use ExUnit.Case, async: true if I want concurrent tests?

I couldn’t find anything in the official docs:

Looks like it default to false

1 Like


It defaults to false like it should. Elixir doesn’t know whether your test depends on some possibly hidden global state or not. Having async: true could cause some of your tests to fail in unpredictable ways which would be hard to debug.

I’d prefer it to default to concurrent, to nudge us into writing code that is safe to run concurrently by default :slight_smile:

1 Like

The problem is that async: true does something different from what people may expect. Tests in single module are always run synchronously, no deviations. async: true mean that tests in given module can be ran in parallel with other modules. So this would produce unexpected results when used with some persistent storage tools, when used without special preparations, or other hard to reason problems. Instead they have chosen to “safer default”. If you want to check your code for concurrency errors then you can check out Concuerror.