feat(gotests): generate tests only for exported func
docs(gotests): generate test for exported funcs
This commit is contained in:
parent
c5096aacc0
commit
b4fd34ec17
4 changed files with 20 additions and 0 deletions
|
|
@ -93,6 +93,12 @@ Generate all tests for all functions/methods in current file
|
||||||
:GoTestsAll
|
:GoTestsAll
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Generate tests only for exported functions/methods in current file
|
||||||
|
|
||||||
|
```vim
|
||||||
|
:GoTestsExp
|
||||||
|
```
|
||||||
|
|
||||||
7. Run `go generate` command
|
7. Run `go generate` command
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
|
|
|
||||||
|
|
@ -56,4 +56,16 @@ function M.all_tests(parallel)
|
||||||
add_test(cmd_args)
|
add_test(cmd_args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---generate unit tests for all exported functions
|
||||||
|
---@param parallel boolean
|
||||||
|
function M.all_exported_tests(parallel)
|
||||||
|
local cmd_args = {}
|
||||||
|
if parallel then
|
||||||
|
table.insert(cmd_args, "-parallel")
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(cmd_args, "-exported")
|
||||||
|
add_test(cmd_args)
|
||||||
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ gopher.get = require "gopher.goget"
|
||||||
gopher.impl = require "gopher.impl"
|
gopher.impl = require "gopher.impl"
|
||||||
gopher.generate = require "gopher.gogenerate"
|
gopher.generate = require "gopher.gogenerate"
|
||||||
gopher.test_add = gotests.one_test
|
gopher.test_add = gotests.one_test
|
||||||
|
gopher.test_exported = gotests.all_exported_tests
|
||||||
gopher.tests_all = gotests.all_tests
|
gopher.tests_all = gotests.all_tests
|
||||||
|
|
||||||
return gopher
|
return gopher
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ command! -nargs=* GoTagAdd :lua require"gopher".tags_add(<f-args>)
|
||||||
command! -nargs=* GoTagRm :lua require"gopher".tags_rm(<f-args>)
|
command! -nargs=* GoTagRm :lua require"gopher".tags_rm(<f-args>)
|
||||||
command! -nargs=* GoTestAdd :lua require"gopher".test_add(<f-args>)
|
command! -nargs=* GoTestAdd :lua require"gopher".test_add(<f-args>)
|
||||||
command! -nargs=* GoTestsAll :lua require"gopher".tests_all(<f-args>)
|
command! -nargs=* GoTestsAll :lua require"gopher".tests_all(<f-args>)
|
||||||
|
command! -nargs=* GoTestsExp :lua require"gopher".test_exported(<f-args>)
|
||||||
command! -nargs=* GoMod :lua require"gopher".mod(<f-args>)
|
command! -nargs=* GoMod :lua require"gopher".mod(<f-args>)
|
||||||
command! -nargs=* GoGet :lua require"gopher".get(<f-args>)
|
command! -nargs=* GoGet :lua require"gopher".get(<f-args>)
|
||||||
command! -nargs=* GoImpl :lua require"gopher".impl(<f-args>)
|
command! -nargs=* GoImpl :lua require"gopher".impl(<f-args>)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue