Skip to content

Commit a53907e

Browse files
committed
improve test file filtering
1 parent 3376e7c commit a53907e

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

lua/neotest-vstest/init.lua

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,20 @@ function DotnetNeotestAdapter.root(path)
4040
end
4141

4242
function DotnetNeotestAdapter.is_test_file(file_path)
43-
return (
44-
(vim.endswith(file_path, ".csproj") or vim.endswith(file_path, ".fsproj"))
45-
and test_discovery.discover_tests(file_path)
46-
)
47-
or (
48-
(vim.endswith(file_path, ".cs") or vim.endswith(file_path, ".fs"))
49-
and test_discovery.discover_tests(file_path)
50-
)
43+
local isTestFile = (vim.endswith(file_path, ".csproj") or vim.endswith(file_path, ".fsproj"))
44+
or (vim.endswith(file_path, ".cs") or vim.endswith(file_path, ".fs"))
45+
46+
if not isTestFile then
47+
return false
48+
end
49+
50+
local tests = test_discovery.discover_tests(file_path)
51+
local n = 0
52+
if tests then
53+
n = #vim.tbl_values(tests)
54+
end
55+
56+
return tests and n > 0
5157
end
5258

5359
function DotnetNeotestAdapter.filter_dir(name)

0 commit comments

Comments
 (0)