Skip to content

ex_unit extractor does not work with ExUnit.CaseTemplate modules #501

@brosquinha

Description

@brosquinha

Hi, apparently, after #480, Expert no longer detects describe/test blocks on its outline tree when using ExUnit.CaseTemplate instead of direct ExUnit.Case.

I've setup a simple reproducible project to demonstrate this issue:

  1. Run mix new test_app --sup (I'm using elixir 1.19.5 and erlang 28.4 here);
  2. Create the following file on lib/my_case.ex (taken directly from ExUnit documentation):
defmodule MyCase do
  use ExUnit.CaseTemplate

  using do
    quote do
      # This code is injected into every case that calls "use MyCase"
      alias TestApp
    end
  end
end
  1. Apply the following diff on test/test_app_test.exs:
defmodule TestAppTest do
- use ExUnit.Case
+ use MyCase
  doctest TestApp

  test "greets the world" do
    assert TestApp.hello() == :world
  end
end

I'm also attaching this generated project here:

new-elixir.tar.gz

I personally rely on this LSP capability to quickly navigate on tests files, and since many production applications use CaseTemplate, this is a big issue for my usage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions