diff --git a/lib/ex_unit/lib/ex_unit/case.ex b/lib/ex_unit/lib/ex_unit/case.ex index 934f638f29..097ef89ea6 100644 --- a/lib/ex_unit/lib/ex_unit/case.ex +++ b/lib/ex_unit/lib/ex_unit/case.ex @@ -223,8 +223,6 @@ defmodule ExUnit.Case do end quote do - async = !!unquote(opts)[:async] - unless Module.has_attribute?(__MODULE__, :ex_unit_tests) do tag_check = [:moduletag, :describetag, :tag] @@ -249,11 +247,17 @@ defmodule ExUnit.Case do @before_compile ExUnit.Case @after_compile ExUnit.Case - @ex_unit_async async + @ex_unit_async false @ex_unit_describe nil use ExUnit.Callbacks end + async = unquote(opts)[:async] + + if is_boolean(async) do + @ex_unit_async async + end + import ExUnit.Callbacks import ExUnit.Assertions import ExUnit.Case, only: [describe: 2, test: 1, test: 2, test: 3] diff --git a/lib/ex_unit/test/ex_unit/case_test.exs b/lib/ex_unit/test/ex_unit/case_test.exs index c1950deba2..6e8b0e5f7d 100644 --- a/lib/ex_unit/test/ex_unit/case_test.exs +++ b/lib/ex_unit/test/ex_unit/case_test.exs @@ -113,3 +113,39 @@ defmodule ExUnit.CaseTest do end end end + +defmodule ExUnit.DoubleCaseTest1 do + use ExUnit.Case, async: true + use ExUnit.Case + + test "async must be true", context do + assert context.async + end +end + +defmodule ExUnit.DoubleCaseTest2 do + use ExUnit.Case, async: false + use ExUnit.Case + + test "async must be false", context do + refute context.async + end +end + +defmodule ExUnit.DoubleCaseTest3 do + use ExUnit.Case, async: true + use ExUnit.Case, async: false + + test "async must be false", context do + refute context.async + end +end + +defmodule ExUnit.DoubleCaseTest4 do + use ExUnit.Case + use ExUnit.Case, async: true + + test "async must be true", context do + assert context.async + end +end