In ExUnit is it possible to mark a single test as non-async? I know that if you do
use MyApp.ChannelCase, async: true
All the tests in the file are marked as async (and likewise for false). But if you want to have most tests async except for a few it appears that you are out of luck.
It would be nice to be able to do:
@tag async: false test "complicated test that uses a genserver or other shared state" do # insert test here end
But that results in
cannot set tag :async because it is reserved by ExUnit. So as far as I can tell the available approaches appear to be:
- Create separate files for the async vs non-async tests
a. I don’t favor this because it’s not obvious from looking at one file that the other one exists with different test cases
- If a single test in a module has to be non-async then make all the tests in that module non-async
Is there an approach that I’m missing? My use case is that I have a service module that creates an entity in the database and also emits a channel message. So since those channels are potentially shared I need the tests to be non-async.