Skip to content

Commit 8701cbe

Browse files
authored
tests: add subfolder detection tests (#53)
1 parent dc77b30 commit 8701cbe

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

spec/samples/test_solution/src/FsharpTest/FsharpTest.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12+
<Compile Include="Subfolder/Subfolder2/Subfolder3/MoreTests.fs" />
1213
<Compile Include="Tests.fs" />
1314
<Compile Include="ManyTests.fs" />
1415
<Compile Include="TestsNUnit.fs" />
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace X.Subfolder.MoreTests
2+
3+
open Xunit
4+
open System.Threading.Tasks
5+
6+
module A =
7+
8+
[<Fact>]
9+
let ``My test in subfolder`` () =
10+
let fx x =
11+
let x = 1
12+
Assert.True(false)
13+
14+
fx ()

spec/test_detection_spec.lua

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,31 @@ describe("Test test detection", function()
5555
assert.are_same(expected_tests, tests)
5656
end)
5757

58+
nio.tests.it("detect tests in subfolder of project", function()
59+
local test_file = solution_path
60+
.. "/src/FsharpTest/Subfolder/Subfolder2/Subfolder3/MoreTests.fs"
61+
local positions = plugin.discover_positions(test_file)
62+
63+
assert.is_not_nil(positions, "Positions should not be nil")
64+
65+
local tests = {}
66+
67+
for _, position in positions:iter() do
68+
if position.type == "test" then
69+
tests[#tests + 1] = position.name
70+
end
71+
end
72+
73+
local expected_tests = {
74+
"My test in subfolder",
75+
}
76+
77+
table.sort(expected_tests)
78+
table.sort(tests)
79+
80+
assert.are_same(expected_tests, tests)
81+
end)
82+
5883
nio.tests.it("detect tests in fsharp file with many test cases", function()
5984
local test_file = solution_path .. "/src/FsharpTest/ManyTests.fs"
6085
local positions = plugin.discover_positions(test_file)
@@ -105,12 +130,29 @@ describe("Test test detection", function()
105130
assert.is_truthy(plugin.filter_dir("CSharpTest", "/src/CSharpTest", solution_path))
106131
end)
107132

133+
nio.tests.it("not filter nested test directory", function()
134+
assert.is_truthy(
135+
plugin.filter_dir(
136+
"Subfolder3",
137+
"/src/FsharpTest/Subfolder/Subfolder2/Subfolder3",
138+
solution_path
139+
)
140+
)
141+
end)
142+
108143
nio.tests.it("identify test file", function()
109144
local test_file = solution_path .. "/src/CSharpTest/UnitTest1.cs"
110145

111146
assert.is_truthy(plugin.is_test_file(test_file))
112147
end)
113148

149+
nio.tests.it("identify test file in subfolder", function()
150+
local test_file = solution_path
151+
.. "/src/FsharpTest/Subfolder/Subfolder2/Subfolder3/MoreTests.fs"
152+
153+
assert.is_truthy(plugin.is_test_file(test_file))
154+
end)
155+
114156
nio.tests.it("filter file in non-test project", function()
115157
local project_file = solution_path .. "/src/ConsoleApp/ConsoleApp.csproj"
116158

0 commit comments

Comments
 (0)