-
-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathinit.lua
More file actions
115 lines (97 loc) · 2.87 KB
/
init.lua
File metadata and controls
115 lines (97 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
local log = require('java-core.utils.log2')
local lsp_utils = require('java-core.utils.lsp')
local get_error_handler = require('java-core.utils.error_handler')
local runner = require('async.runner')
local JavaTestApi = require('java-test.api')
local DapRunner = require('java-dap.runner')
local JUnitReport = require('java-test.reports.junit')
local ResultParserFactory = require('java-test.results.result-parser-factory')
local ReportViewer = require('java-test.ui.floating-report-viewer')
local M = {
---@type java-test.JUnitTestReport
last_report = nil,
}
function M.run_current_class()
log.info('run current test class')
return runner(function()
local test_api = JavaTestApi:new({
client = lsp_utils.get_jdtls(),
runner = DapRunner(),
})
return test_api:execute_current_test_class(M.get_report(), { noDebug = true })
end)
.catch(get_error_handler('failed to run the current test class'))
.run()
end
function M.debug_current_class()
log.info('debug current test class')
return runner(function()
local test_api = JavaTestApi:new({
client = lsp_utils.get_jdtls(),
runner = DapRunner(),
})
test_api:execute_current_test_class(M.get_report(), {})
end)
.catch(get_error_handler('failed to debug the current test class'))
.run()
end
function M.debug_current_method()
log.info('debug current test method')
return runner(function()
local test_api = JavaTestApi:new({
client = lsp_utils.get_jdtls(),
runner = DapRunner(),
})
return test_api:execute_current_test_method(M.get_report(), {})
end)
.catch(get_error_handler('failed to run the current test method'))
.run()
end
function M.run_current_method()
log.info('run current test method')
return runner(function()
local test_api = JavaTestApi:new({
client = lsp_utils.get_jdtls(),
runner = DapRunner(),
})
return test_api:execute_current_test_method(M.get_report(), { noDebug = true })
end)
.catch(get_error_handler('failed to run the current test method'))
.run()
end
function M.run_all_tests()
log.info('run all tests')
return runner(function()
local test_api = JavaTestApi:new({
client = lsp_utils.get_jdtls(),
runner = DapRunner(),
})
return test_api:execute_all_tests(M.get_report(), { noDebug = true })
end)
.catch(get_error_handler('failed to run all tests'))
.run()
end
function M.debug_all_tests()
log.info('debug all tests')
return runner(function()
local test_api = JavaTestApi:new({
client = lsp_utils.get_jdtls(),
runner = DapRunner(),
})
return test_api:execute_all_tests(M.get_report(), {})
end)
.catch(get_error_handler('failed to debug all tests'))
.run()
end
function M.view_last_report()
if M.last_report then
M.last_report:show_report()
end
end
---@private
function M.get_report()
local report = JUnitReport(ResultParserFactory(), ReportViewer())
M.last_report = report
return report
end
return M