-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: cahnge project sturct fix: nested class tests feat: add detailed log for parametrized tests
- Loading branch information
Showing
28 changed files
with
1,508 additions
and
784 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
nvim-versions: ["stable", "nightly"] | ||
|
||
name: test | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v3 | ||
|
||
- uses: rhysd/action-setup-vim@v1 | ||
with: | ||
neovim: true | ||
version: ${{ matrix.nvim-versions }} | ||
|
||
- name: run tests | ||
run: make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
SRC_DIR=lua | ||
TESTS_DIR=tests | ||
TESTS_DIR=./tests | ||
PREPARE_CONFIG=${TESTS_DIR}/prepare-config.lua | ||
TEST_CONFIG=${TESTS_DIR}/minimal_init.lua | ||
|
||
.PHONY: test lint format all | ||
.PHONY: test lint format | ||
|
||
checks: format lint | ||
checks: format lint test | ||
|
||
test: | ||
nvim --headless -c "PlenaryBustedDirectory {minimal_init = '${TEST_CONFIG}'}" | ||
lint: | ||
luacheck ${SRC_DIR} | ||
|
||
format: | ||
~/.cargo/bin//stylua ${SRC_DIR} --config-path=.stylua.toml | ||
|
||
test: | ||
@nvim --headless --noplugin -u ${TEST_CONFIG} \ | ||
-c "PlenaryBustedDirectory ${TESTS_DIR} {minimal_init = '${TEST_CONFIG}'}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
local M = {} | ||
|
||
function M.get_short_error_message(result) | ||
if result.actual and result.expected then | ||
return string.format( | ||
'Expected: [%s] but was [%s]', | ||
result.expected[1], | ||
result.actual[1] | ||
) | ||
end | ||
local trace_result = '' | ||
for idx, trace in ipairs(result.trace) do | ||
trace_result = trace_result .. trace | ||
if idx > 3 then | ||
break | ||
end | ||
end | ||
return trace_result | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
local class = require('neotest-jdtls.utils.class') | ||
local get_short_error_message = | ||
require('neotest-jdtls.junit.common').get_short_error_message | ||
local lib = require('neotest.lib') | ||
local async = require('neotest.async') | ||
local TestStatus = require('neotest-jdtls.types.enums').TestStatus | ||
|
||
---@class DynamicTestResult | ||
---@field invocations string[] | ||
---@field nodes java_test.TestResults[] | ||
local DynamicTestResult = class() | ||
function DynamicTestResult:_init() | ||
self.is_dynamic_test = true | ||
self.invocations = {} | ||
self.nodes = {} | ||
self.status = nil | ||
self.errors = {} | ||
self.output = {} | ||
self.all = {} | ||
end | ||
|
||
function DynamicTestResult:append_invocation(invocation, node) | ||
assert(invocation) | ||
assert(node) | ||
|
||
self.all[invocation] = node | ||
table.insert(self.invocations, invocation) | ||
table.insert(self.nodes, node) | ||
end | ||
|
||
function DynamicTestResult:get_neotest_result() | ||
local all = 0 | ||
for invocation, node in pairs(self.all) do | ||
all = all + 1 | ||
self:append(invocation, node) | ||
end | ||
local results_path = async.fn.tempname() | ||
|
||
table.insert( | ||
self.output, | ||
1, | ||
string.format( | ||
'Total invocations: %s\nSuccess: %s\nFailed: %s\n', | ||
all, | ||
all - #self.errors, | ||
#self.errors | ||
) | ||
) | ||
lib.files.write(results_path, table.concat(self.output, '\n')) | ||
return { | ||
status = self.status, | ||
output = results_path, | ||
errors = self.errors, | ||
} | ||
end | ||
|
||
function DynamicTestResult:append(invocation, node) | ||
table.insert( | ||
self.output, | ||
string.format( | ||
'\n----------------%s----------------', | ||
node.result.status or TestStatus.Passed | ||
) | ||
) | ||
table.insert( | ||
self.output, | ||
string.format('Invocation %s: %s', invocation, node.display_name) | ||
) | ||
table.insert(self.output, '----------------Output----------------') | ||
|
||
if node.result.status == TestStatus.Failed then | ||
local short_message = get_short_error_message(node.result) | ||
self.status = TestStatus.Failed | ||
table.insert(self.errors, { message = short_message }) | ||
table.insert(self.output, table.concat(node.result.trace, '\n')) | ||
else | ||
if self.status == nil then | ||
self.status = TestStatus.Passed | ||
end | ||
table.insert( | ||
self.output, | ||
'The console output is available in the DAP console.\n' | ||
) | ||
end | ||
end | ||
|
||
return DynamicTestResult |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.