@@ -2,37 +2,81 @@ local plugin = require("neotest-java")
22local it = require (" nio" ).tests .it -- async
33
44describe (" file_checker" , function ()
5- it (" should return true for test files" , function ()
6- local test_files = {
7- " src/test/java/neotest/NeotestTest.java" ,
8- " src/test/java/neotest/RepositoryTests.java" ,
9- " src/test/java/neotest/NeotestIT.java" ,
10- " src/test/java/neotest/ProductAceptanceTests.java" ,
11- " src/test/java/neotest/domain/ProductAceptanceTests.java" ,
12- }
13-
14- for _ , file_path in ipairs (test_files ) do
15- assert .is_true (plugin .is_test_file (file_path ))
16- end
17- end )
18-
19- it (" should return false for a java non-test file" , function ()
20- local non_test_files = {
21- " src/test/java/neotest/Configuration.java" ,
22- " src/test/java/neotest/TestRepository.java" ,
23- " src/test/java/neotest/Neotest.java" ,
24- }
25- for _ , file_path in ipairs (non_test_files ) do
26- assert .is_false (plugin .is_test_file (file_path ))
27- end
28- end )
29-
30- it (" should return false for every class inside main folder" , function ()
31- local non_test_files = {
32- " src/main/java/neotest/NeotestTest.java" ,
33- }
34- for _ , file_path in ipairs (non_test_files ) do
35- assert .is_false (plugin .is_test_file (file_path ))
36- end
37- end )
5+ it (" should return true for test files" , function ()
6+ local test_files = {
7+ " src/test/java/neotest/NeotestTest.java" ,
8+ " src/test/java/neotest/RepositoryTests.java" ,
9+ " src/test/java/neotest/NeotestIT.java" ,
10+ " src/test/java/neotest/ProductAceptanceTests.java" ,
11+ " src/test/java/neotest/domain/ProductAceptanceTests.java" ,
12+ }
13+
14+ for _ , file_path in ipairs (test_files ) do
15+ assert .is_true (plugin .is_test_file (file_path ))
16+ end
17+ end )
18+
19+ it (" should return false for a java non-test file" , function ()
20+ local non_test_files = {
21+ " src/test/java/neotest/Configuration.java" ,
22+ " src/test/java/neotest/TestRepository.java" ,
23+ " src/test/java/neotest/Neotest.java" ,
24+ }
25+ for _ , file_path in ipairs (non_test_files ) do
26+ assert .is_false (plugin .is_test_file (file_path ))
27+ end
28+ end )
29+
30+ it (" should return false for every class inside main folder" , function ()
31+ local non_test_files = {
32+ " src/main/java/neotest/NeotestTest.java" ,
33+ }
34+ for _ , file_path in ipairs (non_test_files ) do
35+ assert .is_false (plugin .is_test_file (file_path ))
36+ end
37+ end )
38+
39+ it (" should return true if theres a /main/ outside the root path" , function ()
40+ local ch = require " neotest-java.context_holder"
41+ ch .set_root ' /absolute_path/main/src'
42+ local non_test_files = {
43+ " /absolute_path/main/src/java/neotest/NeotestTest.java" ,
44+ }
45+ for _ , file_path in ipairs (non_test_files ) do
46+ assert .is_true (plugin .is_test_file (file_path ))
47+ end
48+ ch .set_root ' '
49+ end )
50+
51+ it (" should return false if theres a /main/ inside the root path in a windows env" , function ()
52+ vim .fn .win64 = {}
53+ local ch = require " neotest-java.context_holder"
54+ ch .set_root ' C:\\ absolute_path\\ main\\ src'
55+
56+ local non_test_files = {
57+ " C:\\ absolute_path\\ src\\ main\\ java\\ neotest\\ NeotestTest.java" ,
58+ }
59+ for _ , file_path in ipairs (non_test_files ) do
60+ assert .is_false (plugin .is_test_file (file_path ))
61+ end
62+
63+ ch .set_root ' '
64+ vim .fn .win64 = nil
65+ end )
66+
67+ it (" should return true if theres a /main/ outside the root path in a windows env" , function ()
68+ vim .fn .win64 = {}
69+ local ch = require " neotest-java.context_holder"
70+ ch .set_root ' C:\\ absolute_path\\ main\\ src'
71+
72+ local non_test_files = {
73+ " C:\\ absolute_path\\ main\\ src\\ java\\ neotest\\ NeotestTest.java" ,
74+ }
75+ for _ , file_path in ipairs (non_test_files ) do
76+ assert .is_true (plugin .is_test_file (file_path ))
77+ end
78+
79+ ch .set_root ' '
80+ vim .fn .win64 = nil
81+ end )
3882end )
0 commit comments