Forget about opening tmux or another terminal instance to run your file/package tests.
Go tester is a way to avoid the context switching in running a test suite in your golang project.
As soon as you run the command, you can begin to fix all from tests to actual source code, just for the tests to be re-run as soon as you save the files you are coding in.
tjdevries who inspired this plugin to be created. For more information about how it works in practical applications watch This Video
- nvim 0.8.0 or higher
- nvim-treesitter/nvim-treesitter
Using vim-plug
Plug 'nvim-treesitter/nvim-treesitter'
Plug 'nachonievag/go-tester.nvim'
Using dein
call dein#add('nvim-treesitter/nvim-treesitter')
call dein#add('nachonievag/go-tester.nvim')
Using Packer
use {
'nachonievag/go-tester.nvim',
requires = { {'nvim-treesitter/nvim-treesitter'} }
}
You can specify the several flags to execute the go test command.
As it is today the defined command to execute is:
go test $exec_path -v -json
This flags are mandatory for the plugin to work, yet you could add the ones you need at will.
use {
"nachonievag/go-tester.nvim",
requires = "nvim-treesitter/nvim-treesitter",
config = function()
require("go-tester").setup({ flags = { "-failfast", "-race", "-cover" } })
end
}
In this case, we shall see as the user command is executed, that the command executed is:
go test $exec_path -v -json -failfast -race -cover
Commands | Description |
---|---|
GoTestFileOnSave |
Test current buffer on save. |
GoTestPackageOnSave |
Test package where current buffer is located. |
GoTestLineDiag |
After having diagnostics executed, show in split the results of a test. |