go-gen-test
is package for generating tests for go code from
emacs. It is simple wrapper around gotests
.
Generate tests for functions you want to.
If you call this function while region is active it extracts
functions defined in this region and generate tests for it.
Else it generates tests for exported or all functions.
You can customize this behavior with go-gen-test-default-functions
.
Generate tests for all functions.
Generate tests for all exported functions.
M-x customize-group
Enter go-gen-test
Enter
You can now install package go-gen-test
from
MELPA. Just M-x
package-install
Enter go-gen-test
Enter.
Also you should install
gotests
:
$ go get -u github.com/cweill/gotests/...
Then you can bind needed commands to preffered keys:
(defun my-go-gen-test-setup ()
"My keybindings for generating go tests."
(interactive)
(local-set-key (kbd "C-c C-g") #'go-gen-test-dwim))
(add-hook 'go-mode-hook #'my-go-gen-test-setup)