Skip to content

Commit

Permalink
feat: Detect inline tests and tests without a body. Closes #29
Browse files Browse the repository at this point in the history
  • Loading branch information
jfpedroza committed Nov 14, 2023
1 parent 59e32b3 commit 3bc22c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lua/neotest-elixir/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function ElixirNeotestAdapter.discover_positions(path)
(sigil . (sigil_name) @_sigil_name . (quoted_content) @test.name .) (#any-of? @_sigil_name "s" "S") ;; Sigil ~s and ~S, no interpolations
]
)
(do_block)
(do_block)?
) @test.definition
;; Test blocks (dynamic)
Expand All @@ -171,7 +171,7 @@ function ElixirNeotestAdapter.discover_positions(path)
(identifier) ;; Single variable as name
(sigil . (sigil_name) @_sigil_name (interpolation)) (#any-of? @_sigil_name "s") ;; Sigil ~s, with interpolations
] @dytest.name)
(do_block)
(do_block)?
) @dytest.definition
;; Doctests
Expand Down
8 changes: 8 additions & 0 deletions tests/sample_proj/test/sample_proj/parse_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ defmodule SampleProj.ParseTest do
assert SampleProj.hello() == :world
end

test "inline test", do: assert(SampleProj.hello() == :world)

test("inline test with a context", %{}, do: assert(SampleProj.hello() == :world))

test ~s(with the s sigil) do
assert SampleProj.hello() == :world
end

test ~S(with the S sigil) do
assert SampleProj.hello() == :world
end

test "without a body"
end

describe "dynamic tests" do
Expand All @@ -44,6 +50,8 @@ defmodule SampleProj.ParseTest do
assert SampleProj.hello() == :world
end

test "inline #{i}", do: assert(SampleProj.hello() == :world)

for j <- [:foo, :bar] do
test "#{i} nested #{j} test" do
assert SampleProj.hello() == :world
Expand Down

0 comments on commit 3bc22c8

Please sign in to comment.