 
     var = Macro.escape(var)
     contents = Macro.escape(contents, unquote: true)
-
-    quote bind_quoted: [var: var, contents: contents, message: message] do
-      name = ExUnit.Case.register_test(__ENV__, :test, message, [])
+    %{module: mod, file: file, line: line} = __CALLER__
+
+    quote bind_quoted: [
+            var: var,
+            contents: contents,
+            message: message,
+            mod: mod,
+            file: file,
+            line: line
+          ] do
+      name = ExUnit.Case.register_test(mod, file, line, :test, message, [])
       def unquote(name)(unquote(var)), do: unquote(contents)
     end
   end

  display. You can use `ExUnit.plural_rule/2` to set a custom
  pluralization.
  """
  def register_test(%{module: mod, file: file, line: line}, test_type, name, tags) do
    unless Module.has_attribute?(mod, :ex_unit_tests) do
      raise "cannot define #{test_type}. Please make sure you have invoked " <>
              "\"use ExUnit.Case\" in the current module"

  end

  @doc """
  Reigsters a test with the given environment.

  This function is deprecated in favor of register_test/6 which performs
  better under tight loops by avoiding `__ENV__`.
  """
  @doc deprecated: "Use register_test/6 instead"
  def register_test(%{module: mod, file: file, line: line}, test_type, name, tags) do
    register_test(mod, file, line, test_type, name, tags)
  end

  @doc """
  Registers a new attribute to be used during `ExUnit.Case` tests.

  The attribute values will be available through `context.registered`.
